n=int(input())
arr=list(map(int,input().split()))
odd=[]
even=[]
for i in range(len(arr)):
    if  arr[i]%2==0:
        even.append(arr[i])
    else:
        odd.append(arr[i])
even.sort(reverse=True)
odd.sort(reverse=True)
if len(odd)>=len(even):
    odd=odd[len(even)+1:]
    even=[]
else:
    even=even[len(odd)+1:]
    odd=[]
print(sum(even)+sum(odd))
    
    