n=int(input())
l=[int(e.strip()) for e in input().strip().split()]
odd=[]
even=[]
sum=0
for pp in l:
    if pp % 2 == 0:
        even.append(pp)
    else: odd.append(pp)
    sum += pp
odd=sorted(odd, reverse=1)
even=sorted(even, reverse=1)
for i in range(min(len(odd),len(even))):
    sum-=even[i]
    sum-=odd[i]
if(len(odd)>len(even)):
    sum-=odd[len(even)]
if(len(odd)<len(even)):
    sum-=even[len(odd)]
print(sum)