var
a:array[1..20]of longint;
s:array[1..20]of string;
i,j,n:longint;
t:string;
begin
read(n);
for i:=1 to n do
begin
read(a[i]);
str(a[i],s[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if s[i]+s[j]<s[j]+s[i] then
begin
t:=s[i];
s[i]:=s[j];
s[j]:=t;
end;
for i:=1 to n do
write(s[i]);
end.
a:array[1..20]of longint;
s:array[1..20]of string;
i,j,n:longint;
t:string;
begin
read(n);
for i:=1 to n do
begin
read(a[i]);
str(a[i],s[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if s[i]+s[j]<s[j]+s[i] then
begin
t:=s[i];
s[i]:=s[j];
s[j]:=t;
end;
for i:=1 to n do
write(s[i]);
end.