
import sys,os
from collections import Counter, defaultdict



# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
n = map(int, raw_input().split())[0]
da = map(int, raw_input().split())
od = [i for i in da if i%2 == 1]
ev = [i for i in da if i%2 == 0]
od.sort()
ev.sort()
if len(od) > len(ev):
    print sum(od[:-len(ev)-1])
else:
    print sum(ev[:-len(od)-1])
