n=input()
l= list(map(int,input().split()))
l.sort()

even=[]
odd=[]
for x in l[::-1]:
    if x%2==0:
        even.append(x)
    else:
        odd.append(x)
        
diff=len(even)-len(odd)
if diff==0:
    print(0)
elif diff>0:
    print(sum(even[len(even)-diff+1:]))
elif diff<0:
    print(sum(odd[len(odd)+diff+1:]))
    
    