n = int(raw_input())
nums = map(int, raw_input().split())

pares, impares = [], []
for i in xrange(n):
    if nums[i] % 2 == 0:
        pares.append(nums[i])
    else:
        impares.append(nums[i])

ti, tp = len(impares), len(pares)

ans = 0
if abs(ti - tp) > 1:
    pares.sort()
    impares.sort()

    i, p = ti - 1, tp - 1
    while (i >= 0 and p >= 0):
        impares.pop(-1)
        pares.pop(-1)
        i -= 1
        p -= 1

    soma = 0
    tp, ti = len(pares), len(impares)
    if tp > 0:
        pares.pop(-1)
        tp -= 1
        for k in xrange(tp):
            soma += pares[k]
    if ti > 0:
        impares.pop(-1)
        ti -= 1
        for l in xrange(ti):
            soma += impares[l]

    ans = soma

print ans