IN = input
rint = lambda: int(IN())
rlist = lambda: list(map(int, IN().split()))

n = rint()
a = []
b = []
for i in rlist():
    if i & 1:
        a.append(i)
    else:
        b.append(i)
a.sort()
b.sort()
s = 0


def upd(x): global s; s = max(s, x)


def Try(a, b):
    t = min(len(a), len(b))
    upd(sum(a[-t - 1:]) + sum(b[-t - 1:]))


Try(a, b)
Try(b, a)
print(sum(a) + sum(b) - s)
