Minimizing the expected time to get a string of heads with biased coins Imagine you have $n$ coins. Coin $i$ has a probability $p_i$ to get heads. You can choose these probabilities so long as $\sum_{i=1}^n p_i = \alpha$ for some constant $\alpha \leq n$. Now that you've chosen the probabilities, you must play a game. Flip coin 1; if it comes up tails, you must restart the game. However, if it comes up heads, flip coin 2; if it comes up tails, you must restart the game. To win the game you must flip $n$ heads in a row. You want to assign the probabilities $p_i$ such that the expected number of coin flips is minimized.
Note that if the question were to assign $p_i$ such that the probability of winning is maximized, a standard result is to choose $p_i = \frac{\alpha}{n}$ for all $i$.
Formally, this problem can be stated as:
$$\min_{p_i} E_n \text{ where } E_n = \left(n \prod_{i=1}^n p_i + \sum_{i=1}^n (E_n + i) \ p_1 p_2 \ldots p_{i-1} (1 - p_i)\right)$$
With the following constraints:
$$\sum_{i=1}^n p_i = \alpha \text{ and } p_i \in [0, 1]$$
In the case of $n=2$ this is easy, we have $p_2 = \alpha - p_1$ and:
$$E_2 = 2 p_1 (\alpha - p_1) + (E_2 + 1)(1 - p_1) + (E_2 + 2)p_1(1 - \alpha + p_1)$$
Solving for $E_2$ and setting $\frac{\partial E_2}{\partial p_1} = 0$, we eventually find:
$$p_1 = \sqrt{1 + \alpha} - 1$$
For $\alpha = 1$, this gives $p_1 \approx 0.414$. This agrees with intuition - instead of doling out the probabilities equally, you should favor lower probabilities for low indices $i$ and higher probabilities for high indices $i$. When $\alpha \geq 2$, we would expect the formula to return $p_1 \geq 1$, since $p_1 = p_2 = 1$ is optimal, but for some reason it does not do this.
However, it already becomes very difficult when $n=3$. Is there a general way to attack this problem?

I'm able to derive the following:
$$E_n = \frac{1 + p_1 + p_1 p_2 + \ldots + p_1 p_2 \cdots p_{n-1}}{p_1 p_2 \cdots p_n}$$
Using the method of Lagrange multipliters, I can get the following $n+1$ nonlinear equations in $n+1$ variables:
$$\frac{\partial E_n}{\partial p_i} = -\frac{1 + p_1 + p_1 p_2 + \ldots + p_1 p_2 \cdots p_{i-1}}{p_1 p_2 \cdots p_{i-1} p_i^2 p_{i+1} \cdots p_n} + \lambda = 0$$
$$\frac{\partial E_n}{\partial \lambda} = p_1 + p_2 + \ldots + p_n - \alpha = 0$$
But I don't see how to solve this set of nonlinear equations.
 A: Edit. Corrected massive typos. Now everything is working and looks consistent with other answers and comments.
Here I am not answering the original question, but this question needs a clarification.
First, the quantity you wrote is not the correct one to minimize to find the optimal values of $p_1,\dots, p_n$. You can simply choose $p_1=0$ (as long as $\alpha\leq n-1$) to make that quantity achieve the minimum. That quantity is simply the average number of coin flips needed to either win the game or to score tails once.
The quantity you want to minimize is then slightly different.(the original post has been corrected).
The expected value of coin flips in your problem is given by
$$ E_n=al+n, $$
where the number $a$ is the average number of coin flips before losing the game once assuming you are going to lose,
$$ a=\frac{\sum_{i=1}^{n}ip_1\cdots p_{i-1}(1-p_i)}{\sum_{i=1}^{n}p_1\cdots p_{i-1}(1-p_i)}, $$
and the number $l$ is the average number of tails (losses) before winning the game (computed using the formula of the mean value of a geometric distribution)
$$ l=\frac{1}{p_1\cdots p_n}-1. $$
(the $-1$ comes from the fact that I am counting the very last $n$ coin flips separately). It is then possible to simplify the quantity to the expression
$$ E_n=\frac{\sum_{i=1}^{n}ip_1\cdots p_{i-1}(1-p_i)}{p_1\cdots p_n}+n= \frac{\left(\sum_{i=1}^{n-1}ip_1\cdots p_{i-1}(1-p_i)\right) +np_1\cdots p_{n-1}}{p_1\cdots p_n} $$
which further simplifies to
$$ E_n=\frac{1+p_1+p_1p_2+\dots + p_1\cdots p_{n-1}}{p_1\cdots p_n}. $$
An easy recursive formula, which could be helpful in finding a way of computing the minimum expected value, is then given by
$$ E_n=\frac{E_{n-1}+1}{p_n}. $$
I have checked carefully that all the steps work and the formula is consistent with the formula of @Henry in one of the comments (thanks!). How to find the optimal values of $p_1,...,p_n$ I don’t see at the moment.
A: For the $n=2$ case, I would have said $$E=(1+E)(1-p_1)+(2+E)p_1(1-p_2)+2p_1p_2$$  implying $$E=\frac{1+p_1}{p_1p_2}$$ as the expected number of throws until you get two consecutive heads.
If you also know $p_1+p_2=\alpha$ then you want to minimise $\frac{1+p_1}{p_1(\alpha -p_1)}$.  This will certainly need $0 \le p_1 \le p_2\le 1$ and so happens when $p_1=\sqrt{\alpha+1}-1$ as your corrected calculations show.
However, if $\alpha \gt \phi$ the golden ratio $\frac{1+\sqrt{5}}2\approx 1.618$, then this is no longer satisfactory as it would suggest optimal $p_2 >1$ so not a probability.  In that case the optimal probabilities are $p_2=1$ and $p_1=\alpha-1$. This resolves your concern about what happens when $\alpha =n=2$.
