num=int(input())
arr=list(map(int,input().split()))
odd=[]
even=[]
for i in arr:
  if i%2==0:
    even.append(i)
  else:
    odd.append(i)
if len(odd)<len(even):
  print(sum(even[:len(even)-len(odd)-1]))
else:
  print(sum(odd[:len(odd)-len(even)-1]))
