N = int(input())
A = list(sorted((int(t) for t in input().split()[:N]), reverse=True))

evens = [ai for ai in A if ai % 2 == 0]
odds = [ai for ai in A if ai % 2 == 1]
emax = sum(evens[:2]) if len(evens) >= 2 else -1
omax = sum(odds[:2]) if len(odds) >= 2 else -1

print(max(emax, omax))
