n = int(input())
l = list(map(int, input().split()))
e = []
o = []
for i in range(len(l)):
    if(l[i]%2==0):
        e.append(l[i])
    else:
        o.append(l[i])
e.sort()
o.sort()
e.reverse()
o.reverse()
#print(e," ",o)
s = 0
if(len(e)>len(o)):
    for i in range(len(o)+1,len(e)):
        s+=e[i]
    print(s)
    
elif(len(e)<len(o)):
    for i in range(len(e)+1,len(o)):
        s+=o[i]
    print(s)
else:
    print(0)