def reverse_num(x): return int(str(x)[::-1]) n = int(input()) a = list(map(int, input().split())) # 將所有能力值倒轉 a = [reverse_num(x) for x in a] # 找出最大值 ans = max(a) print(ans)