#555 3 2

import sys

count = sys.stdin.readline().rstrip()

line = sorted([int(i) for i in sys.stdin.readline().rstrip().split(" ")])
evens = []
odds = []
for i in line:
    if i % 2 == 0:
        evens.append(i)
    else:
        odds.append(i)
while len(odds) > 0 and len(evens) > 0:
    del odds[-1]
    del evens[-1]
print(sum(odds[:-1]) + sum(evens[:-1]))
