uses crt;
var n,i,t:integer;
{----------------chuong-trinh-con-kiem-tra-so-nguyen-to----------------------}
function ktnt(x:integer):boolean;
var kt:boolean;
n,i:integer;
begin
kt:=true;
for i:=2 to x-1 do
if x mod i=0 then kt:=false;
if kt=true then ktnt:=true
else ktnt:=false;
end;
{------------------chuong-trinh-chinh---------------------}
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=2 to n do
if ktnt(i)=true then
begin
write(i:4);
t:=t+i;
end;
writeln;
writeln('Tong cac so nguyen to la: ',t);
readln;
end.