t = int(input())
l = list(map(int,input().split()))
l.sort()
l1=[]
l2=[]
for i in l:
  if i%2==0:
    l1.append(i)
  else:
    l2.append(i)
x = abs(len(l1)-len(l2))-1
if x==0:
  print(x)
elif x >0 and len(l1)>len(l2):
  print(sum(l1[:x]))
elif x >0 and len(l1)<len(l2):
  print(sum(l2[:x]))
elif x <0 and len(l1)==len(l2):
  print(0)