import math

n=int(input())
a=[int(i) for i in input().split()]
even=sorted([i for i in a if i%2==0])
odd=sorted([i for i in a if i%2==1])
if abs(len(even)-len(odd))<=1:
    print(0)
elif len(even)>len(odd):
    one=even[:len(even)-len(odd)-1]
    print(sum(one))
else:
    one=odd[:len(odd)-len(even)-1]
    print(sum(one))