import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) S=[input() for _ in range(n)] import heapq H=[] ans="" for i in range(n): heapq.heappush(H,S[i]+"~") while H: a=heapq.heappop(H) ans+=a[0] if len(a)>2: heapq.heappush(H,a[1:]) print(ans)