n = int(input())
l = list(map(int, input().split()))
e = []
o = []
for i in l:
    if i % 2 == 0:
        e.append(i)
    else:
        o.append(i)
num = min(len(o), len(e))
r = 0
if len(o) > len(e):
    l1 = num+1
    l2 = num
elif(len(e) > len(o)):
    l1 = num
    l2 = num+1
else:
    r = 1
if r == 0:
    for i in range(l1):
        o.remove(max(o))
    for i in range(l2):
        e.remove(max(e))
    print(sum(o) + sum(e))
else:
    print("0")

