import sys
import math 

strInp = lambda : input().strip().split()
intInp = lambda : list(map(int,strInp()))

n = int(input())
arr = intInp()

even = []
odd = []

for i in arr:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

even.sort()
odd.sort()
if abs(len(even) - len(odd)) < 2:
    print(0)
else:
    if len(odd) > len(even):
        print(sum(odd[0:(len(odd)-len(even))-1]))
    else:
        print(sum(even[0:(len(even)-len(odd))-1]))            


