P1654 OSU!
Step 1
We can split the expectation down to each position instead of calculating it as a whole. We have: $\(l^3 - (l-1)^3 = 3l^2 - 3l + 1\)$ $\(\mathbb{E} = \sum{\mathbb{E}[3l_i^2-3l_i+1]}\)$ $\(\mathbb{E}[l_i] = p_i(\mathbb{E}[l_{i-1}] + 1)\)$ $\(\mathbb{E}[l_i^2] = p_i \mathbb{E}[(l_{i-1} + 1)^2] = p_i(\mathbb{E}[l_{i-1}^2] + 2\mathbb{E}[l_{i-1}] + 1)\)$ We can simply iterate.