Hi I'm new and I need some help

I have a column with data values and I will need add it up until the total is <=40 so that I will need to insert a page break; then I will need to continue reading the data and do the same until finish.
Any ideas how can I do this, please.

Data
5
20
15
15
10
30
1
9

See below this example

5
20
15
Insert page brake
15
10
Insert page brake
30
1
9
Insert page brake