n=int(input())
l=list(map(int,input().split()))
odd=[]
even=[]
for i in l:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)
odd.sort(reverse=True)
even.sort(reverse=True)
if abs(len(odd)-len(even))==1:
    print(0)
else:
    o=len(odd)
    e=len(even)
    if o>e:
        print(sum(odd[e+1:]))
    elif e>o:
        print(sum(even[o+1:]))
    else:
        print(0)