n=int(input())
a=list(map(int,input().split()))
odd=[]
even=[]
a.sort()
for i in range(0,n):
    if a[i]&1:
        odd.append(a[i])
    else:
        even.append(a[i])
if len(odd)==len(even):
    print(0)
elif len(odd)==(len(even)-1) or (len(odd)-1)==len(even):
    print(0)
else:
    if max(len(odd),len(even))==len(odd):
        diff=len(odd)-len(even)-1
        print(sum(odd[0:diff]))
    else:
        diff = len(even)-len(odd)-1
        print(sum(even[0:diff]))
        
    
