n = int(input())
a = list(map(int, input().split()))
ch = []
nec = []
for x in a:
    if x % 2 == 0:
        ch.append(x)
    else:
        nec.append(x)
ch.sort()
nec.sort()
if len(ch) - 1 > len(nec):
    print(sum(ch[:len(ch) - len(nec) - 1]))
elif len(nec) - 1 > len(ch):
    print(sum(nec[:len(nec) - len(ch) - 1]))
else:
    print(0)