import sys

n = int(input())

a = [int(c) for c in input().split()]

evens = [i for i in a if i % 2 == 0]
odds = [i for i in a if i % 2 != 0]
evens.sort()
odds.sort()

if abs(len(evens) - len(odds)) <= 1:
  print(0)
elif len(evens) > len(odds):
  print(sum(evens[:len(evens)-len(odds)-1]))
else:
  print(sum(odds[:len(odds)-len(evens)-1]))
