n = int(input())

num = list(map(int, input().split()))
e = o = 0
even = [0]*n
odd = [0]*n
num = sorted(num)

for i in range(n):
    if num[i]%2==0:
        even[e] = num[i]
        e+=1
    else:
        odd[o] = num[i]
        o+=1

dif = abs(e-o)

if dif == 0 or dif == 1:
    print("0")
else:
    soma = 0
    if e>o:
        for i in range(dif-1):
            soma += even[i]
    else:
        for i in range(dif-1):
            soma += odd[i]

    print(soma)