===================================================
Explanation:
To make a 5 digit number as large as possible, given the set of values {1,8,3,4,9,6,2,7}, we will pick digits that are as large as possible as we move from left to right. I'm assuming we can't re-use digits. If we could, then I would pick all 9's.
9 is the largest, 8 is the second largest, then 7, then 6, then 4. We can't use 5 since it is not in the set mentioned.
The largest five-digit number we can form is 98764
Subtract off 40 to get the final answer
98764 - 40 = 98724