n=int(input())
a=list(map(int,input().split()))
odd,even=[],[]
for _ in range(n):
    if a[_]%2==0:
        even.append(a[_])
    else:
        odd.append(a[_])
odd.sort(reverse=True)        
even.sort(reverse=True)
x1=len(even)
x2=len(odd)
if x2>x1:
    print(sum(odd[x1+1:]))
else:
    print(sum(even[x2+1:]))
    
