n = int(input())
a = [int(x) for x in input().split()]
b = [x for x in a if x % 2 == 0]
c = [x for x in a if x % 2 != 0]

b.sort(reverse=True)
c.sort(reverse=True)
if len(b) < len(c):
    b, c = c, b
s = 0
for i in range(len(c) + 1, len(b)):
    s += b[i]
print(s)
