var n,i,j:longint;
a:array[1..100000]of ansistring;
// aa,bb:ansistring;
procedure swap(var a,b:ansistring);
var t:string;
begin
t:=a; a:=b; b:=t;
end;
procedure qsort(l,r:longint);
var i,j:longint;
mid:ansistring;
begin
i:=l; j:=r; mid:=a[(l+r) div 2];
repeat
while a[i]>mid do inc(i);
while a[j]<mid do dec(j);
if i<=j then begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end;
begin
readln(n);
for i:=1 to n+1 do a[i]:=chr(1);
for i:=1 to n do readln(a[i]);
qsort(1,n);
{for i:=1 to n do begin
if a[i]+a[i+1]<a[i+1]+a[i] then swap(a[i],a[i+1]);
end;}
for i:=1 to n-1 do
for j:=i+1 to n do
if (a[i]+a[j])<(a[j]+a[i]) then swap(a[i],a[j]);
for i:=1 to n do write(a[i]);
writeln;
close(input);
close(output);
end.