What is the sum of natural numbers that have $5$ digits or less, and all of the digits are distinct? $1+2+3+\dots+7+8+9+10+12+13+\dots+96+97+98+102+103+104+\dots+985+986+987+1023+1024+1025+\dots+9874+9875+9876+10234+10235+10236+\dots+98763+98764+98765=$
The only thing I can do is to evaluate a (bad) upper bound by evaluating the sum of natural numbers from $1$ to $98765$, that is equal to $98765 \times (98765+1)/2=4,877,311,995$. So the desired answer is less than that.
Any help would be appreciated. Thanks.

Allow $0$ as a lead digit, and regard $025$ as different from $25$.  Then the average of each digit is $4.5$.  Finally, remove numbers whose first digit is $0$, and whose other digits have average $5$.
So there are $10$ one-digit numbers, average $4.5$, $90$ two-digit numbers, average $4.5 ×11$, $720$ three-digit and so on.
Then subtract $9$ two-digit numbers that start with $0$ with average $5$, $72$ three-digit numbers starting with $0$ and average $55$, and so on.
