n = int(input())
a = list(map(int, input().split()))
s = sum(a)
odd = [i for i in a if i&1]
odd.sort(reverse = True)
even = [i for i in a if i&1==0]
even.sort(reverse = True)
if len(odd) > len(even):
  print(s-sum(odd[:len(even)+1])-sum(even))
elif len(odd) < len(even):
  print(s-sum(even[:len(odd)+1])-sum(odd))
else:
  print(0)
