n = int(input())
a = list(map(int, input().split()))
odd = []
even = []
for i in range(n):
    if a[i] % 2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])
ans = 0
odd.sort()
even.sort()

if -1 <= len(odd) - len(even) <= 1:
    ans = 0
elif len(odd) > len(even):
    ans = sum(odd[:(len(odd)-len(even)-1)])
else:
    ans = sum(even[:(len(even)-len(odd)-1)])
print(ans)
