n=int(input())
l=[int(x) for x in input().split()]
even=[]
odd=[]
for i in range(n):
    if l[i]%2==0:
        even.append(l[i])
    else: odd.append(l[i])
e=len(even)
o=len(odd)
even.sort()
odd.sort()
if e==0:
    print(sum(odd[:-1]))
elif o==0:
    print(sum(even[:-1]))
elif e-o==0:
    print("0")
elif e-o==1 or o-e==1:
    print("0")
else:
    if e>o:
        print(sum(even[:e-o-1]))
    else:
        print(sum(odd[:o-e-1]))
    