var
a:array[0..1100]of string;
i,j,k,l,m,n:longint;
begin
assign(input,'brick.in');reset(input);
assign(output,'brick.out');rewrite(output);
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
for j:=1 to n-1 do
if a[j]+a[j+1]<a[j+1]+a[j] then
begin
a[0]:=a[j];a[j]:=a[j+1];a[j+1]:=a[0];
end;
for i:=1 to n do write(a[i]);
writeln;
close(input);close(output);
end.