from math import *
def sumx(z,t):
    count = 0
    for i in range(t):
        count = count + z[i]
    return count
n = int(input())
a = list(map(int,input().split()))
b =[]
c =[]
for i in a:
    if i % 2 == 0:
        b.append(i)
    else:
        c.append(i)
d = sorted(b)
e = sorted(c)
f = abs(len(d)-len(e))
if f == 1 or 0:
    print(0)
else:
    if len(d) > len(e):
        print(sumx(d,f-1))
    else:
        print(sumx(e,f-1))
