n = int(input())
arr = list(map(int,input().split()))
odd = []
even = []
for i in arr:
    if i%2:
        odd.append(i)
    else:
        even.append(i)
odd = sorted(odd)
even = sorted(even)

if abs(len(odd)-len(even))<=1:
    print(0)
else:
    if len(odd)< len(even):
        print(sum(even[:len(even)-len(odd)-1]))
    else:
        print(sum(odd[:len(odd)-len(even)-1]))
