def mp():
    return map(int, input().split())

n = int(input())
a = list(mp())

e = o = 0
for i in a:
    if i % 2 == 0:
        e += 1
    else:
        o += 1

a.sort()

if e >= o:
    t = 0
    cnt = e - o - 1
else:
    t = 1
    cnt = o - e - 1

r = 0
for i in a:
    if i % 2 == t and cnt > 0:
        cnt -= 1
        r += i
        
print(r)