N = int(input())
odd, eve = [], []
L = list(map(int, input().split()))

for i in L:
    if i % 2 == 0:
        eve += [i]
    else:
        odd += [i]
        
eve.sort()
odd.sort()
deL = min(len(eve), len(odd)) + 1
ans = 0
if len(eve) > deL:
    ans += sum(eve[:len(eve) - deL])
if len(odd) > deL:
    ans += sum(odd[:len(odd) - deL])
print(ans)