n=int(input())
odd=[]
even=[]
for num in input().split():
    num=int(num)
    if num%2==0:
        even.append(num)
    else:
        odd.append(num)

on = len(odd)
en = len(even)
if abs(on-en)<=1:
    print(0)
else:
    diff = abs(on-en)-1
    if on>en:
        odd.sort()
        print(sum(odd[:diff]))
    else:
        even.sort()
        print(sum(even[:diff]))
