N = int(input()) X = 36 ** 1000 for _ in range(N): S = input() M = int(max(S), 36) + 1 X = min(X, int(S, M)) print(X)