import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListSet; public class Main { public static final int C = 1000000007; static final int CY = 1000000000; //static boolean MAP[][]; static int N; static int M; static int[][] DIF; static String S; static int K; static int X[][]; //static String S[]; static int HA[]; static long DP[]; static int ST[][]; static ConcurrentSkipListSet TS; static ArrayList AL; public static void main(String[] args) { StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); N = sc.nextInt(); BigInteger ans = new BigInteger("ZZZZZZZZZZZZ", 36); String[] strs = new String[N]; for (int i=0; i < N; i++) { String str = sc.next(); strs[i] = str; int d = 1; for (int t=0; t < str.length(); t++) { d = Math.max(d, str.charAt(t) - '0' +1); } if (d > 10) { d-=7; } BigInteger num = new BigInteger(strs[i], d); ans = ans.min(num); } System.out.println(ans); } }