import heapq n = int(input()) hp = [] for _ in range(n): si = input() heapq.heappush(hp, si + "~") ans = [] while len(hp) > 0: cur = heapq.heappop(hp) if len(cur) == 1: continue elif len(hp) == 0: ans.append(cur[:-1]) else: ans.append(cur[0]) heapq.heappush(hp, cur[1:]) print("".join(ans))