This is a typical application of Wald's identity: if are i.i.d. integrable random variables and is an integrable stopping time, then letting , we have:

.(This generalizes to martingales; in fact, either you prove it directly in this case or you use a general martingale theorem for the (bounded) martingale )

In your case, you don't know where , but you know it is between 1000 and 1004.