n =  int(input())
f= list(map(int,input().split()))
e = []
o=[]
for i in range(n):
    if f[i]%2==0:
        e.append(f[i])
    else:
        o.append(f[i])
e.sort(reverse =True)
o.sort(reverse  = True)

if len(e)>len(o)+1:
    print(sum(e[len(o)+1:]))
elif len(o)>len(e)+1:
    print(sum(o[len(e)+1:]))
else:
    print(0)
    
    
