Let X\_k be the variable equal to 1 if the numbers in positions 1, 2, 3, ...., k are all > the number picked initially (in position 0), and 0 otherwise. Then the question is asking for the expectation of 1 + X\_1 + X\_2 + ... + X\_(n-1), which is the same as the sum of the expectations for each term.

The probability that X\_k = 1 can be found this way. First, the probability that all the numbers in positions 1, ..., k are distinct from the initial number is 1 - k/n. Next assuming that that is the case, the probability that of the numbers in positions 0, 1, 2, ..., k, the smallest is the one in position 0 is 1/(k + 1). So E(X\_k) = (1 - k/n)/(k+1) = (1+1/n)/(k+1) - 1/n.

Adding those terms up we get 1 + (1 + 1/n)(1/2 + 1/3 + ... + 1/n) - (n - 1)/n = (1 + 1/n)(1 + 1/2 + 1/3 + ... + 1/n) - 1, which agrees with the answer given by u/Megame50