n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
for i in range(n):
    if a[i]%2==0:
        b.append(a[i])
    else:
        c.append(a[i])
b.sort()
c.sort()
if len(b)>len(c):
    print(sum(b[:(len(b)-len(c)-1)]))
elif len(b)==len(c):
    print(0)
else:
    print(sum(c[:(len(c)-len(b)-1)]))