numero = int(input())

lista = raw_input().split()
par = []
impar = []
s = 0
for i in range(len(lista)):
    s += int(lista[i])
    if int(lista[i])%2:
        par.append(int(lista[i]))
    else:
        impar.append(int(lista[i]))

sorted(par, reverse = True)
sorted(impar, reverse = True)

"""if len(par) == len(impar):
    print("0")
    quit()

if (len(par) > len(impar)):
    del par[len(par)-1]
    while(len(impar) >0):
        del impar[len(impar)-1]
        del par[len(par)-1]
else:
    del impar[len(impar)-1]
    while(len(par) >0):
        del par[len(par)-1]
        del impar[len(impar)-1]
"""

ans = 2000000000
t = 0

l = 0
r = 0
for j in range(0, 2):
    k = j
    while(1):
        if k:
            if l == len(par):
                break
            t += par[l]
            l += 1
        else:
            if r == len(impar):
                break
            t += impar[r]
            r += 1
        k = 1-k
    ans = min(ans, s-t)
print(ans)
