from bisect import insort
n = int(input())
e = []
o = []
for v in map(int, input().split()):
    if v & 1:
        insort(o, v)
    else:
        insort(e, v)
le = len(e)
lo = len(o)
de = max(le - lo - 1, 0)
do = max(lo - le - 1, 0)
print(sum(e[:de]) + sum(o[:do]))