def SI(): return input()
def II(): return int(SI())
def STI(): return SI().split()
def ITI(): return map(int, STI())
def SLI(): return list(SI())
def ILI(): return list(ITI())


n = II()
a = ILI()

e, o = [], []
la = len(a)
for i in range(la):
    e.append(a[i]) if a[i] % 2 == 0 else o.append(a[i])

result = 0
le = len(e)
lo = la - le
if le > lo + 1:
    oe = sorted(e)
    result = sum(oe[:le-lo-1])
if le + 1 < lo:
    oo = sorted(o)
    result = sum(oo[:lo-le-1])

print(result)
