n= int(input())
s=[int(i) for i in input().split()]
a=[]
b=[]
for i in s:
    if(i%2==0):
        a.append(i)
    else:
        b.append(i)
a.sort()
b.sort()
c=0
if(len(a)<len(b)):
    for i in range(0,len(b)-len(a)-1):
        c=c+b[i]
elif(len(a)>len(b)):
    for i in range(0,len(a)-len(b)-1):
        c=c+a[i]
else:
    c=0
print(c)