n=int(input())
a=[int(i) for i in input().split()]
e=[]
o=[]
for i in range(n):
    if a[i]%2==0:
        e.append(a[i])
    else:
        o.append(a[i])
e.sort(reverse=True)
o.sort(reverse=True)
if len(o)<len(e):
    s=sum(e[len(o)+1:len(e)])
elif len(e)<len(o):
    s=sum(o[len(e)+1:len(o)])
else:
    s=0
print(s)