n = int(input())
L = list(map(int, input().split()))
odd = [x for x in L if x&1 == 1]
even = [x for x in L if x&1 != 1]
k = max(0, abs(len(even) - len(odd)))
kL = odd if len(odd) > len(even) else even
kL.sort()
print(sum(kL[0:k-1]) if k !=0 else 0)