from heapq import * n = int(input()) hq = [input() for _ in range(n)] heapify(hq) ans = [] while hq: S = heappop(hq) ans.append(S[0]) S = S[1:] if S: heappush(hq, S) print(*ans, sep="")