import math
n = int(input())
o =[]
e=[]
s = list(map(int, input().split()))
for i in s:
    if i%2==0:
        e.append(i)
    else:
        o.append(i)
if abs(len(e)-len(o))<=1:
    print(0)
else:
    if len(e)>len(o):
        k = len(e)-len(o) - 1
        e.sort()
        su = 0
        for i in range(k):
            su+=e[i]
        print(su)
    else:
        k = len(o)-len(e) - 1
        o.sort()
        su = 0
        for i in range(k):
            su+=o[i]
        print(su)
