program ghillie;
const
infile='ghillie.in';
outfile='ghillie.out';
var
b:array[1..10000] of 1..500;
a:array[1..300] of boolean;
i,j,k:longint;
bk,n,m,x,y,z,sx,sy,sz:qword;
begin
assign(input,infile);reset(input);
assign(output,outfile);rewrite(output);
fillchar(a,sizeof(a),false);
m:=0;sx:=1;sy:=1;sz:=1;bk:=0;
readln(n);
while not eof do begin
read(i);
if i>m then m:=i;
a[i]:=true;
end;
for i:= 1 to n do begin
for j:=1 to m do
if a[j] then begin
x:=j div 100;
y:=(j div 10)mod 10;
z:=j mod 10;
for k:=1 to i+1 do begin
sx:=sx*x;
sy:=sy*y;
sz:=sz*z;
end;
inc(bk);
if sx+sy+sz>300 then b[bk]:=0 else b[bk]:=sx+sy+sz;
sx:=1;sy:=1;sz:=1;
end;
for k:=1 to bk do
a[b[k]]:=false;
end;
for i:=1 to bk do
a[b[i]]:=false;
for i:=1 to m do
if a[i] then write(i,' ');
close(input);close(output);
end.