a = int(input())
s = input()
l5 = s.split()
l=[]
for i in l5:
    l.append(int(i))
l.sort()
e = 0
o = 0
l1 = []
l2 = []
for i in l:
    if (i % 2 == 0):
        l1.append(i)
        e = e + 1
    else:
        l2.append(i)
        o = o + 1
sum = 0
if (e > o):
    for i in range(0, len(l1) - 1 - o, 1):
        sum = sum + l1[i]
elif (o > e):
    for i in range(0, len(l1) - 1 - e, 1):
        sum = sum + l2[i]
else:
    sum = 0
print(sum)

