a = int(input())
s = [int(x) for x in input().split()]
s.sort(reverse=True)
e1 = []
e2 = []
for i in s:
  if i % 2 != 0:
    e1.append(i)
  else:
    e2.append(i)
if len(e1) == len(e2):
  print(0)
else:
  if len(e1) < len(e2):
    print(sum(e2[len(e1) + 1:]))
  else:
    print(sum(e1[len(e2) + 1:]))