n = int(input())
lis = list(map(int, input().split()))
odd =  []
even = []
for i in lis:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i)
odd = sorted(odd, reverse = 1)
even = sorted(even, reverse = 1)

res = 0
length = min(len(odd), len(even))
for _ in range(length):
    even.remove(even[0])
    odd.remove(odd[0])

if len(odd) > 0:
    odd.remove(odd[0])
elif len(even) > 0:
    even.remove(even[0])

print(sum(odd) + sum(even))