input()
n = [int(x) for x in input().split()]
# n = input()
odd = []
even = []

for e in n:
    if e & 1 == 0:
        even += [e]
    else:
        odd += [e]
even = sorted(even)
odd = sorted(odd)

def solve():
    if len(even) == len(odd):
        return 0
    elif len(even) > len(odd):
        return sum(even[0:len(even) - 1 -len(odd)])
    else:
        return sum(odd[0:len(odd) - 1 - len(even)])

print(solve())

