n = int(input())
ai = list(map(int,input().split()))
ai.sort()
num = 0
for i in range(n):
    if ai[i] % 2 == 0:
        num += 1
num2 = min(num,n-num) * 2 + 1
num4 = 0
if n - num > num:
    num4 = 1
num3 = max(0,n - num2)
ans = 0
for i in range(n):
    if num3 == 0:
        break
    if ai[i] % 2 == num4:
        num3 -= 1
        ans += ai[i]
print(ans)
