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