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