even = [0]
odd = [0]
n = int(input())
b = list(map(int, input().split()))
for i in range(n):
    a = b[i]
    if a % 2 == 1:
        odd.append(a + odd[len(odd) - 1])
    else:
        even.append(a + even[len(even) - 1])
if len(odd) > len(even):
    print(odd[len(odd)-len(even)-1])
elif len(even) > len(odd):
    print(even[len(even)-len(odd)-1])
else:
    print(0)
