Willson the Canada Goose is like any other Canada Goose - he now has several goslings (baby geese) to take care of!
Willson has goslings, numbered from to , that are currently feeding on grass. There are many patches of grass in the field that they are in, in fact, for all from to , there are infinitely many patches of grass containing blades of grass.
The goslings are also bored, so they decide to play a game. The goslings will take turns eating all the blades of grass in one patch. However, each gosling must consume a patch with a strictly greater number of blades than the previous gosling. The goslings will take turns in order starting from , and will cycle around, that is, gosling will take a turn after gosling .
However, goslings have different appetites. The gosling can eat up to blades of grass in total. A gosling will not eat from a patch if consuming the whole patch would result in its eating more than blades in total.
The goslings agree that in the end, each gosling must consume the same number of patches. Thus, the game can only end after gosling takes his turn. Note that the goslings must play in a way that they can always choose a patch to eat before the end of the game, and that it is possible that no gosling eats any grass.
Willson is interested in his children's game and wonders about the maximum total number of blades of grass that can be eaten by the goslings. Can you tell him?
Constraints
Subtask | Percentage | Additional Constraints |
---|---|---|
No additional constraints. |
Input Specification
The first line of input will contain and .
lines of input follow. The line will contain . It is guaranteed that .
Output Specification
Output on a single line the maximum total number of blades of grass that can be eaten.
Sample Input
2 6
6
15
Sample Output
16
Explanation for Sample Output
The game could go like this:
- Gosling 1 eats 1 blade
- Gosling 2 eats 4 blades
- Gosling 1 eats 5 blades
- Gosling 2 eats 6 blades
Comments