var
N, J: Word;
sum: Integer;
function factorial(N : word) : longint;
var
i : integer;
f : longint;
begin
f := 1;
for i := 2 to n do
f := f * i;
factorial := f
end;
begin
write('Введите N: ');
readLn(N);
sum := 0;
for J := 1 to N do Inc(Sum, Factorial(J));
write('Сумма равна: ');
writeLn(Sum);
end.