#l = list(map(int, input().strip().split()))

n = int(input())
l = list(map(int, input().strip().split()))

p = []
d = []

for i in range(n):
    if l[i] % 2 == 0:
        p += [l[i]]
    else:
        d += [l[i]]
p = sorted(p)[::-1]
d = sorted(d)[::-1]

if abs(len(p) - len(d)) <= 1:
    print(0)
else:
    if len(p) > len(d):
        print(sum(p[len(d)+1:]))
    else:
        print(sum(d[len(p)+1:]))