For the answer to be 40: add the solution to the previous line to the numbers on the next line,
1 + 4 = 5
5 + 2 + 5 = 12
12 + 3 + 6 = 21
21 + 8 + 11 = 40
For the answer to be 96: multiply the first number by the second number, then add the outcome to the first number,
1 + (1 x 4) = 5
2 + (2 x 5) = 12
3 + (3 x 6) = 21
8 + (8 x 11) = 96
(Telegraph)