n = int(input())
a = list(map(int , input().split(' ')))
f = list(map(lambda x : x % 2 == 0, a))

e = f.count(True)
o = f.count(False)

r = e - o
if abs(r) < 2:
    print(0)
else:
    plus = []
    minus = []
    for i in a:
        if i % 2 == 0:
            plus.append(i)
        else:
            minus.append(i)
    if r > 0:
        plus.sort()
        print(sum(plus[:r - 1]))
    else:
        minus.sort()
        print(sum(minus[:abs(r) - 1]))