I'm having issues with understanding exactly how Expected Values work, I understand what they are, just not how to get them in all cases. One of the problems I'm having trouble is involves two teams that play a series of games and ends when one of them has won i games. Each game is, independently, won by team A with probability p. Find the expected number of games that are played when i=2 and i=3, also show how a p=1/2 maximizes this number in both cases. I understand what the expected value represents here and what not, just not sure how to set up the problem using p and i to find E(x). Can anyone help me with this?