Allen has 405 marbles.
Justin gave him 112. Allen now has 405+112=517 marbles.
Allen gave away 25, so he has 517-25=492 marbles.
An equation for Allen in one line is 405+112-25=492, so Allen gained 112-25=87 marbles and 405+87=492 (possible hidden question).