Oil production speed of flowline =3-(40-24)/ 16=2 (ton/min)
So: Start 8 minutes: Q=3t.
16 minutes later: Q=t+24
Finally: Q=40-2t.