import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b, c = [], []
for i in a:
    if i % 2:
        b.append(i)
    else:
        c.append(i)
b.sort()
c.sort()
bb, cc = len(b), len(c)
if abs(bb - cc) <= 1:
    ans = 0
else:
    if bb > cc:
        ans = sum(b[:(bb - cc - 1)])
    else:
        ans = sum(c[:(cc - bb - 1)])
print(ans)