n=int(input())
a=list(map(int,input().split()))
chet=0
nechet=0
mchet=[]
mnechet=[]
for i in range(n):
    if a[i]%2==0:
        chet=chet+1
        mchet.append(a[i])
    else:
        nechet=nechet+1
        mnechet.append(a[i])
mnechet.sort()
mchet.sort()
nech=nechet-chet
ch=chet-nechet
if nech>=2:
    s=mnechet[:nech-1]
elif ch>=2:
    s=mchet[:ch-1]
else:
    s=[0]
print(sum(s))

