Can you check if every number exists? If yes you may try this:
S = sum of all numbers in the bag (S < 5050)
Z = sum of the missing numbers 5050 - S
if the missing numbers are x
and y
then:
x = Z - y and
max(x) = Z - 1
So you check the range from 1
to max(x)
and find the number