n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()
odd = []
even = []
for x in a:
    if x % 2 == 0:
        even.append(x)
    else:
        odd.append(x)

x = min(len(odd), len(even)) + 1
print(sum(odd[x:]) + sum(even[x:]))