n=int(input())
a=list(map(int,input().split()))
e=[]
o=[]
for i in range(len(a)):
    if(a[i]%2 == 0):
        e.append(a[i])
    else:
        o.append(a[i])
e=sorted(e)
o=sorted(o)
s=0
if(len(e) > len(o)):
    d=len(e)-len(o)
    d-=1
    for i in range(d):
        s+=e[i]
    print(s)
elif(len(e) < len(o)):
    d=len(o)-len(e)
    d-=1
    for i in range(d):
        s+=o[i]
    print(s)
else:
    print(0)