n = int(input())
a = list(map(int, input().split()))
odd, even= [], []
for x in a:
  if x % 2 == 1:
    odd.append(x)
  else:
    even.append(x)
odd.sort()
even.sort()
if abs(len(odd) - len(even)) <= 1:
  print(0)
elif len(odd) - len(even) > 1:
  print(sum(odd[:(len(odd) - len(even) - 1)]))
else:
  print(sum(even[:(len(even) - len(odd) - 1)]))