n=int(input())
a=sorted(list(map(int,input().split())))
odd,even=[],[]
o,e=0,0
for i in range(n):
    if a[i]&1:
        o+=1
        odd.append(a[i])
    else:
        e+=1
        even.append(a[i])
odd.sort()
even.sort()
if abs(o-e)==1 or e==o:
    print(0)
else:
     if e>=o:
         print(sum(even[:-(o+1)]))
     else:
         print(sum(odd[:-(e+1)]))