n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
count1=0
count2=0
for i in range(n):
  if arr[i]%2==0:
    count1+=1
  else:
    count2+=1
ans=0
count3=0
if count1>count2:
  l=count1-count2-1
  diff=0
else:
  l=count2-count1-1
  diff=1
for i in range(n):
  if l<=count3:
    break
  if arr[i]%2==diff:
    ans+=arr[i]
    count3+=1
print(ans)