n=int(input())
b=[int(n) for n in input().split()]
ev=[]
od=[]
a=sorted(b)
for i in range (n):
    if a[i]%2==0:
        ev.append(a[i])
    else:
        od.append(a[i])
s=0
if len(ev)==len(od) or abs(len(ev)-len(od))==1 :
    print("0")
elif len(ev)>len(od):
    for j in range (len(ev)-len(od)-1):
        s+=ev[j]
    print(s)
elif len(ev)<len(od):
    for j in range (len(od)-len(ev)-1):
        s+=od[j]
    print(s)