n = int(input())
l = list(map(int,input().split(" ")))
even = [x for x in l if x%2==0]
odd = [x for x in l if x%2==1]
even = sorted(even)
odd = sorted(odd)
if len(even)==len(odd)or (abs(len(even)-len(odd))==1):
  print(0)
elif len(odd)==0:
  print(sum(even[:-1]))
elif len(even)==0:
  print(sum(odd[:-1]))
else:
  l1 = len(even)
  l2 = len(odd)
  if(l2>l1):
    print(sum(odd[:l2-l1-1]))
  else:
    print(sum(even[:l1-l2-1]))
