n=int(input())

t=list(map(int,input().split()))

even =[]
odd =[]
e,o=0,0
for j in t:
    if j%2==0:
        even.append(j)
        e+=1
    else:
        odd.append(j)
        o+=1

even.sort()
odd.sort()

if e<o:
    if e==0:
        print(sum(odd[0:-1]))
    else:
        print(sum(odd[0:-(e+1)]))

elif o<e:
    if o==0:
        print(sum(even[0:-1]))
    else:
        print(sum(even[0:-(o+1)]))
else:
    print(0)
