n=int(input())
s=list(map(int,input().split()))
even=[i for i in s if i%2==0]
odd=[i for i in s if i%2==1]
even.sort()
odd.sort()
if len(even)>=len(odd):
    s=len(even)-len(odd)-1
    if s<=0:
        print(0)
        exit()
    else:
        print(sum([even[i] for i in range(s)]))
elif len(odd)>=len(even):
    s=len(odd)-len(even)-1
    if s<=0:
        print(0)
        exit()
    else:
        print(sum([odd[i] for i in range(s)]))




    
