n = int(input())
l = list(map(int, input().split()))
ch = 0
nech = 0
ach =[]
anech = []
for i in range(n):
    if l[i] % 2 == 0:
        ach.append(l[i])
        ch += 1
    else:
        nech += 1
        anech.append(l[i])

if nech >= ch:
    anech.sort()
    ans = 0
    for i in range(nech - ch - 1):
        ans += anech[i]
    print(ans)
else:
    ach.sort()
    ans = 0
    for i in range(ch - nech - 1):
        ans += ach[i]
    print(ans)