var
a:array[1..1000000] of longint;
n,i:longint;
procedure xuli(n:longint);
var i:longint;s:int64;
begin
s:=0;
if n<>1 then s:=1;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then
begin
s:=s+i;
if n div i<>i then
s:=s+ n div i;
//writeln(s);
end;
if (s=n) and (s<>0) then writeln(n,' la so hoan chinh');
end;
begin
readln(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
xuli(a[i]);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,t,j:integer;
begin
clrscr;
write('n='); readln(n);
if (n<=0) or (n>100) then writeln('vui long nhap lai')
else begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{---------------------------xu-ly---------------------------}
writeln('cac so hoan chinh trong day la: ');
for i:=1 to n do
begin
t:=0;
for j:=1 to a[i]-1 do
if a[i] mod j=0 then t:=t+j;
if t=a[i] then write(a[i]:4);
end;
end;
readln;
end.