a=int(input())
b=map(int,input().split())
odd=[]
even=[]
sm=0
for i in b:
    if(i%2):
        odd.append(i)
    else:
        even.append(i)
even.sort(reverse=True)
odd.sort(reverse=True)
a=len(even)
b=len(odd)
if(a==b):
    print(0)
elif(a<b):
    print(sum(odd[a+1:]))
else:
    print(sum(even[b+1:]))
