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)

odd.sort(reverse=True)
even.sort(reverse=True)

if(len(even)>len(odd)):
    print(sum(even[len(odd)+1:]))
else:
    print(sum(odd[len(even)+1:]))