n = int(input())
a = list(map(int, input().split(" ")))
o = []
e = []
for i in range(n):
    if a[i]%2==0:
        e.append(a[i])
    else:
        o.append(a[i])
en = len(e)
on = len(o)
e.sort(reverse = True)
o.sort(reverse = True)
m = min(en, on)
s = 0
if en<on:
    s = sum(o[m+1:])
elif en>on:
    s = sum(e[m+1:])
print(s)