import java.util.*; import java.lang.*; import java.math.*; public class Main { void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); boolean flg = true; BigInteger ans = BigInteger.ZERO; for(int i = 0; i < N; i++) { String v = sc.next(); for(int radix = 2; radix < 37; radix++) { try { BigInteger tmp = new BigInteger(v, radix); if(flg == true || ans.compareTo(tmp) == 1) { ans = tmp; flg = false; } } catch(Exception e) { // do nothing } } } System.out.println(ans); } public static void main(String[] args) { new Main().run(); } }