Let us assume the number of tickets sold in advance = x
Let us assume the number of tickets they need to sell at the door = y
Cost of the tickets sold at the door = $5
Cost of the tickets sold in advance = $4
Total amount of money they need to collect = $400
Then
4x + 5y = 400
Now, we already know that the number of tickets sold in advance = 40
Then
(4 * 40) + 5y = 400
160 + 5y = 400
5y = 400 - 160
5y = 240
y = 48
From the above deduction, it can be easily concluded that the number of tickets that they need to sell at the door is 48.