uses crt;
var n,i,s:longint;
{---Ham-nguyen-to---}
function nt(n:longint):boolean;
var i:longint;
begin
i:=2;
while n mod i<>0 do inc(i);
if i=n then
nt:=true
else
nt:=false;
end;
{---Chuong-trinh-chinh---}
begin
clrscr;
write('Nhap n: '); read(n);
for i:=2 to n do
if nt(i) then
inc(s,i);
writeln('Tong nguyen to: ',s);
readln
end.