n = int(input())
a = list(map(int, input().split()))
x = []
y = []
for i in a:
    if i%2 == 0:
        x.append(i)
    else:
        y.append(i)
s = len(x)-len(y)
ans = 0
x.sort()
y.sort()
if s < -1:
    for i in range(0, abs(s)-1):
        ans += y[i]
elif s > 1:
    for i in range(0, s-1):
        ans += x[i]
print(ans)