n = int(input())
arr = [int(x) for x in input().split()]
#print(arr)
aO = []
aE = []
Co = 0
Ce = 0
for i in range(n):
    if (arr[i] % 2 == 0):
        Ce +=1
        aE.append(arr[i])
    else:
        Co += 1
        aO.append(arr[i])
if (Co == Ce):
    print(0)
    raise SystemExit
ans = 0
if (Co > Ce):
    aO.sort()
    Co -= Ce + 1
    for i in range(Co):
        ans += aO[i]
else:
    aE.sort()
    Ce -= Co + 1
    for i in range(Ce):
        ans += aE[i]
print(ans)
