def findParity(x):
    if(x%2==0):
        return 0
    return 1
n=int(input())
a=map(int,raw_input().split())
e=[]
o=[]
for i in a:
    if(findParity(i)==1):
        o.append(i)
    else:
        e.append(i)
o.sort()
e.sort()
p=min(len(o),len(e))
ans=0
if(len(o)>len(e)):
    for i in range(len(o)-p-1):
        ans+=o[i]
    for i in range(len(e)-p):
        ans+=e[i]
else:
    for i in range(len(o)-p):
        ans+=o[i]
    for i in range(len(e)-p-1):
        ans+=e[i]
print ans
