n=int(input())
a=list(map(int,input().split()))
even=[]
odd=[]
for i in a:
    if i&1:
        odd.append(i)
    else:
        even.append(i)
odd.sort(reverse=True)
even.sort(reverse=True)
lo=len(odd)
le=n-lo
if lo>le:
    print(sum(odd[le+1:]))
else:
    print(sum(even[lo+1:]))