n=int(input())
arr=[int(x) for x in input().split()]
arr=sorted(arr)
even=[]
odd=[]
od=0
e=0
for i in arr:
    if i&1:
        odd.append(i)
        od+=1
    else:
        even.append(i)
        e+=1
l=abs(od-e)-1
if l==0 or l==-1:
    print(0)
else:
    if od>e:
        print(sum(odd[:l]))
    else:
        print(sum(even[:l]))
