n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
e = []
o = []
for i in a:
    if i % 2 == 0:
        e.append(i)
    else:
        o.append(i)
l_e = len(e)
l_o = len(o)
c = e
if l_o > l_e:
    c = o
t = max(l_e, l_o) - min(l_e, l_o) - 1
s = 0
if t > 0:
    s = sum(c[:t])
print(s)
