n = int(input())
s = list(map(int, input().split()))
all = sum(s)
odd = sorted([i for i in s if i % 2 == 1])
odd = odd[::-1]
even = sorted([i for i in s if i % 2 == 0])
even = even[::-1]
k = min(len(odd) - 1, len(even) - 1)
all -= sum(odd[:k + 1])
all -= sum(even[:k + 1])
if len(odd) > len(even):
    all -= odd[k + 1]
elif len(even) > len(odd):
    all -= even[k + 1]
print(all)
