#Author : Ashraf Tasin
#Date   : 31.03.19


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

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

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

ans=0

if e>=o:
    c=e-o-1
    for i in range(c):
        ans+=even[i]
    print(ans)
    
else:
    c=o-e-1
    for i in range(c):
        ans+=odd[i]
    print(ans)