import math._ object Main { def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val n = sc.nextInt val xs = (1 to n) map { e => sc.next } var ans = java.lang.Long.MAX_VALUE for (x <- xs) { val c = x.max val base = if (c.isDigit) c - '0' + 1 else c - 'A' + 11 ans = min(ans, java.lang.Long.parseLong(x, base)) } println(ans) } }