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) { int idx = 0; while (idx < s1.length() && idx < s2.length()) { if (s1.charAt(idx) != s2.charAt(idx)) { return s1.charAt(idx) - s2.charAt(idx); } idx++; } return s2.length() - s1.length(); } }); for (int i = 0; i < n; i++) { queue.add(new StringBuilder(sc.next())); } StringBuilder sb = new StringBuilder(); while (queue.size() > 0) { StringBuilder out = queue.poll(); sb.append(out.charAt(0)); out.deleteCharAt(0); if (out.length() > 0) { queue.add(out); } } System.out.println(sb); } }