print(max(filter(lambda x: x%4==0,[int(input()) for i in range(int(input()))])))