t=int(input())
s=list(map(int,input().split()))
s.sort()
a=[]
b=[]
even=0
odd=0
for i in range(t):
    if s[i]%2==0:
        even=even+1
        a.append(s[i])
    else:
        odd=odd+1
        b.append(s[i])
if even==odd+1 or odd==even+1 or odd==even:
    print("0")
else:
    a.sort()
    b.sort()
    if even>odd:
        z=even-odd
        print(sum(a[:z-1]))
    else:
        z=odd-even
        print(sum(b[:z-1]))

        

    
