Given an alphabet of $n$ symbols with probabilities $p_i$ for symbol $i$, we need to encode the symbols (in a prefix-free way) to minimize the expression
$$a(1-a)L,$$
where $L$ is the average code length for a symbol, and $a$ is the percentage of bit $1$ in a large number of coded symbols. Apparently Huffman code is not optimal in this particular context. Is there a way to find the optimal code?