n = input()
a = sorted(map(int, raw_input().split()))

e = []
o = []
for i in range(n):
    if a[i] % 2 == 0: e.append(a[i])
    else: o.append(a[i])

z = 0
m = min(len(e), len(o)) + 1

if len(e) > len(o):
    i = max(0, len(e) - m)
    z = sum(e[:i])
else:
    i = max(0, len(o) - m)
    z = sum(o[:i])

print z
