n = int(input())
a = list(map(int,input().split()))
eve = [x for x in a if x%2==0]
odd = [x for x in a if x%2!=0]
eve.sort(reverse = True)
odd.sort(reverse = True)
point = min(len(eve),len(odd))
point+=1
ans = 0
if len(eve)>point:
    ans = sum(eve[point:])
elif len(odd)>point:
    ans = sum(odd[point:])


print(ans)