function f(a:integer):integer;
var i:integer;
begin
for i:=1 to a do
if (a mod i = 0) then
f+=1;
end;
var
a,b,c:array of integer;
i,n,maxd,max,min,l:integer;
begin
readln(t,n);
setlength(a,n);
setlength(b,n);
setlength(c,n);
for i:=0 to n-1 do
read(t,a[i]);
min:=a[1];
max:=a[2];
for i:=0 to n-1 do
begin
if a[i]<min then min:=a[i];
if a[i]>max then max:=a[i];
end;
l:=0;
for min:=min to max do
for i:=0 to n-1 do
if a[i]=min then
begin
c[l]:=min;
inc(l);
end;
for i:=0 to n-1 do
b[i]:=f(c[i]);
maxd:=b[1];
for i:=0 to n-1 do
if b[i]>maxd then maxd:=b[i];
for maxd:=maxd downto 0 do
for i:=0 to n-1 do
if b[i]=maxd then write(t,c[i],' ');
end.