n=input()
nums=map(int,raw_input().split())
oddNum,evenNum=[],[]
for num in nums:
  if num%2:
    oddNum.append(num)
  else:
    evenNum.append(num)
oddNum.sort();evenNum.sort()
rem=min(len(oddNum),len(evenNum))
if rem:
  oddNum=oddNum[:-rem]
  evenNum=evenNum[:-rem]
ans=0
if evenNum:
  evenNum.pop()
  ans=sum(evenNum)
elif oddNum:
  oddNum.pop()
  ans=sum(oddNum)
print ans
