a=int(input())
b=list(map(int,input().split()))
odd=[]
even=[]
for i in b:
    if i&1:
        odd.append(i)
    else:
        even.append(i)
odd.sort()
even.sort()
x=len(odd)
y=len(even)
if x>=y:
    v=x-y
    if v==0 or v==1:
        print(0)
    else:
        v=v-1
        print(sum(odd[:v]))
else:
    v=y-x-1
    print(sum(even[:v]))
    