import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); PriorityQueue queue = new PriorityQueue(new Comparator() { public int compare(StringBuilder s1, StringBuilder s2) { if (s1.charAt(0) == s2.charAt(0)) { if (s1.length() == 1) { return 1; } else if (s2.length() == 1) { return -1; } else { return s1.compareTo(s2); } } else { return s1.charAt(0) - s2.charAt(0); } } }); while (0 < n--) { queue.add(new StringBuilder(sc.next())); } StringBuilder ans = new StringBuilder(); while (queue.size() > 0) { StringBuilder sb = queue.poll(); ans.append(sb.charAt(0)); sb.deleteCharAt(0); if (sb.length() > 0) { queue.add(sb); } } System.out.println(ans); } }