n=int(input())
a=[int(i) for i in input().split()]
e=[]
o=[]
p=0
s=sum(a)
for i in a:
    if(i%2==0):
        e.append(i)
    else:
        o.append(i)
d=len(e)
f=len(o)
mi=0
if(d<f):
    mi=d
else:
    mi=f
e.sort(reverse=True)
o.sort(reverse=True)
for i in range(mi):
    s=s-e[i]
    s=s-o[i]
if(len(e)>mi):
    s=s-e[mi]
if(len(o)>mi):
    s=s-o[mi]
print(s)