import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); String[] inputs = new String[N]; for(int i = 0; i < N; i++){ inputs[i] = sc.next(); } StringBuilder sb = new StringBuilder(); PriorityQueue queue = new PriorityQueue(); for(int i = 0; i < N; i++){ queue.add(inputs[i] + "{"); } while(!queue.isEmpty()){ final String p = queue.poll(); //System.out.println(p); if(p.equals("{")){ break; } sb.append(p.charAt(0)); if(p.length() != 1){ queue.add(p.substring(1, p.length())); } } System.out.println(sb.toString()); } }