program tinhtong;
uses crt;
var i, s, n : integer;
a : array [1..100] of integer;
begin
clrscr;
write('So thu n la: '); readln(n);
s:=0
for i:=1 to n do begin
write('Nhap so thu ',i); readln(a[i]);
s:=s+a[i]; end;
writeln('Tong cac so do la: ',s);
readln
end.
uses crt;
var a:array[1..100]of integer;
n,i,dem,x,kt,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n>0;
dem:=1;
a[1]:=2;
x:=2;
repeat
x:=x+1;
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then
begin
inc(dem);
a[dem]:=x;
end;
until dem=n;
t:=0;
for i:=1 to dem do
t:=t+a[i];
writeln('Tong cua ',n,' so nguyen to dau tien la: ',t);
readln;
end.