"""
NTC here
"""
from sys import setcheckinterval,stdin
setcheckinterval(1000)

iin=lambda :int(stdin.readline())
lin=lambda :list(map(int,stdin.readline().split()))

n=iin()
a=lin()
ea=[]
oa=[]
for i in a:
    if i%2==0:ea.append(i)
    else:oa.append(i)
l1=len(ea)
l2=len(oa)
ea.sort()
oa.sort()
ans=0
if l1>l2:
    x=l1-l2-1
    ans+=sum(ea[:x])
elif l1<l2:
    x=l2-l1-1
    ans+=sum(oa[:x])

print(ans)    