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

e=[]
o=[]
i=0
sum=int(0)
while i<len(arr):
  if arr[i]%2==0:
    e.append(arr[i])
  else:
    o.append(arr[i])  
  sum=sum+arr[i]
  i+=1
o.sort()
e.sort()
ind=-1
mn=min(len(o),len(e))
mn*=-1

while ind>=mn:
  sum-=o[ind]
  sum-=e[ind]
  ind-=1

if len(o)>len(e):
  sum-=o[ind]
elif len(e)>len(o):
  sum-=e[ind]
print(sum)  
     



   