n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
a.reverse()
x1 = []
y = []
for x in a:
    if x % 2 == 0:
        y.append(x)
    else:
        x1.append(x)
 
x = min(len(x1), len(y)) + 1
print(sum(x1[x:]) + sum(y[x:]))
