n = int(input())
lst = [int(i) for i in input().split()]
even = []
odd = []
for i in lst:
    if i%2:
        odd.append(i)
    else:
        even.append(i)
even = sorted(even)
odd = sorted(odd)
if len(even) == len(odd) or abs(len(even)-len(odd)) == 1:
    print(0)
elif len(even) > len(odd):
    print(sum(even[:len(odd)+1]))
else:
    print(sum(odd[:len(even)+1]))