n=int(raw_input())
 
a=raw_input().split(" ")
 
a=[int(item) for item in a]
 
even=[]
odd=[]
 
i=0
while i<n:
    if a[i]%2==0:
        even.append(a[i])
    else:
        odd.append(a[i])
    i+=1
   
even.sort(reverse = True)
odd.sort(reverse = True)
diff=abs(len(even)-len(odd))
if diff==0 or diff ==1:
    print(0)
else:
    if len(even)>len(odd):
        print(sum(even[len(odd)+1:]))
    else:
        print(sum(odd[len(even)+1:]))