uses crt;
var a,b,k:array[1..100] of integer;
n,i,j,m:integer;
function sohoanhao(q:integer):boolean;
var s,w:integer;
begin
s := 0;
for w := 1 to q-1 do if q mod w=0 then s:=s+w;
if s=q then sohoanhao:=true else sohoanhao:=false;
end;
begin
write('Nhap n:');readln(n);
for i := 1 to n do begin write('Nhap so thu ',i,':');readln(k[i]);end;
for i:=1 to n do
if sohoanhao(k[i])=true then
begin
inc(j);
a[j]:=k[i];
end
else begin
inc(m);
b[m]:=k[i];
end;
writeln('Mang a:');
for i := 1 to j do write(a[i],#32);
writeln;
writeln('Mang b:');
for i := 1 to m do write(b[i],#32);
readln
end.