n = int(input())
l = list(map(int,input().split()))
even = sorted([x for x in l if x%2 == 0],reverse = True)
odd = sorted([x for x in l if x%2],reverse = True)
steps_even = 0
steps_odd = 0
if len(odd) == len(even):
    steps_even = len(odd)
    steps_odd = len(even)
elif len(odd) > len(even):
    steps_odd = len(even)+1
    steps_even = len(even)
else:
    steps_odd = len(odd)
    steps_even = len(odd)+1

total = sum(even[steps_even:])+sum(odd[steps_odd:])
print (total)