n=int(input())
a=list(map(int,input().split()))
even,odd=[],[]
ev,od=0,0
for i in range(n):
    if a[i]%2==0:
        even.append(a[i])
        ev+=1 
    else:
        odd.append(a[i])
        od+=1 
even.sort()
odd.sort()
if ev>0 and od==0:
    even.pop(0)
    print(sum(even))
    exit(0)
elif ev==0 and od>0:
    odd.pop(0)
    print(sum(odd))
    exit(0)
    
sum1=0
if abs(ev-od)<=1:
    print(0)
else:
    
    if ev-od>0:
        for i in range(len(even)-abs(ev-od)):
            sum1+=even[i]
        print(sum1)
    else:
        for i in range(len(odd)-abs(ev-od)):
            sum1+=odd[i]
        print(sum1)
    