Once, a king called all his pages and lined them up. He gave the first page a certain number of ducats, the second page two ducats less, the third page again two ducats less, and so on. When he reached the last page, he gave him the appropriate number of ducats, turned around, and proceeded in the same manner back to the beginning of the row (i.e., he gave the second-to-last page two ducats less than he had just given the last page, etc.). In this round, the first page received two ducats. Then one of the pages noticed that he had 32 ducats.

How many pages could the king have had, and how many ducats could he have distributed in total? Determine all possibilities.

(K. Pazourek)

Hint. How many times did each page receive ducats?
The last page boy received ducats only once, while the other page boys received them twice.

However, the second-to-last page boy received double what the last one did: first 2 ducats more than the last one, then 2 ducats less.

Everyone except the last page boy received the same amount: first, each received 2 ducats more than the next neighbor in line, then 2 ducats less than the same neighbor.

Additionally, the number of ducats the last page boy received was double the number of page boys: the king gradually reduced the contribution by 2 ducats, and in the second round, the first page boy received 2 ducats.

Thus, there are two possibilities:

- The last page boy had 32 ducats. Therefore, there were 16 page boys, and each of the other 15 page boys had 64 ducats. The king distributed a total of $15 \cdot 64 + 32 = 992$ ducats.
- All page boys except the last one had 32 ducats. Therefore, the last one had 16 ducats, and there were 8 page boys. The king distributed a total of $7 \cdot 32 + 16 = 240$ ducats.

The king could have had 16 page boys and distributed 992 ducats, or 8 page boys and 240 ducats.