n = int(input())
a = list(map(int, input().split(' ')))
ach = []
anech = []
for i in range(n):
    if a[i] % 2 == 0:
        ach.append(a[i])
    else:
        anech.append(a[i])
if abs(len(ach) - len(anech)) < 2:
    print(0)
elif len(ach) - len(anech) > 1:
    ach.sort()
    print(sum(ach[:len(ach) - len(anech) - 1]))
else:
    anech.sort()
    print(sum(anech[:len(anech) - len(ach) - 1]))
