n=int(input())
b=list(map(int,input().split()))
c=[]
d=[]
for j in range(n):
    if b[j]%2==0:
        c.append(b[j])
    else:
        d.append(b[j])
c.sort()
c.reverse()

d.sort()
d.reverse()
if len(c)>len(d):
    print(sum(c[len(d)+1:]))
elif len(d)>len(c):
    print(sum(d[len(c) + 1:]))
else:
    print(0)


