#Author : Ashraf Tasin
#Date   : 31.03.19

n=int(input())
odd=[]
even=[]
o=0
e=0

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

for i in range(0,n):
    x=ins[i]
    if x%2==0:
        even.append(x)
        e+=1
    else:
        odd.append(x)
        o+=1

if e-o==0 or abs(e-o)==1 :
    print("0")
    quit()

ans=0

if e>o:
    c=e-o-1
    odd.sort()
    even.sort()

    for i in range(0,c):
        ans+=even[i]
        
    print(ans)
    
else:
    c=e-o-1
    odd.sort()
    even.sort()

    for i in range(0,c):
        ans+=odd[i]
        
    print(ans)