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

even = sorted([i for i in a if i % 2 == 0], reverse=True)
odd = sorted([i for i in a if i % 2 != 0], reverse=True)

s = sum(a)

r = s

k = min(len(even), len(odd))

r -= sum(even[:k])
r -= sum(odd[:k])

if len(odd) > k:
    r -= odd[k]
if len(even) > k:
    r -= even[k]
print(r)

