Expectation formula

how did we calculate the expectation formula? I know thats its 1/P(success) but i am not able to understand how we came across the entire formula…