n = int(input())
a = list(map(int, input().split()))

odd = [x for x in a if x%2 != 0]
even = [x for x in a if x%2 == 0]

even.sort(reverse=True)
odd.sort(reverse=True)

ne = len(even)
no = len(odd)
if abs(ne-no) <= 1:
  print(0)
else:
  if ne > no:
    print(sum(even[no+1:]))
  else:
    print(sum(odd[ne+1:]))