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