
n=int(input())
a=list(map(int,input().split()))
odd=[]
even=[]
a.sort()
a=a[::-1]
for i in a:
    if i%2==0 and i!=1:
        even.append(i)
    else:
        odd.append(i)
if abs(len(odd)-len(even))<2:
    ans=0
else:
    i=len(odd)
    j=len(even)
    while i>0 and j>0:
        odd.pop(0)
        even.pop(0)
        i-=1
        j-=1
    if len(odd)>0:
        odd.pop(0)
        ans=sum(odd)
    else:
        even.pop(0)
        ans=sum(even)
print(ans)
