I am not a magician, this magic should be a more traditional program.
There are four people, 1, 2, 3, 4, and the first three are randomly generated to confuse the audience.
But there must be something wrong with this person on the 4 th, because he means four digits, which can determine how much the whole number adds up. He should know the number in the envelope. When he quoted the number 1, 2, 3, he secretly added up these numbers, and then subtracted the sum of 1, 2, 3 from the number in the envelope to get the number he wanted to quote. The result is as you can see.
Personal thoughts, I don't know if it's right, I hope it can inspire you.