After DSAA class, Jackie wants to buy lunch food.

There
are n shops in a circle, which are labelled from 1 to n. Each shop has infinity
food, and the price of the food at i-th shop is A_{i}. Jackie will
start his shopping by following the circle “1 -> 2 -> 3 … -> n -> 1->2->...” to buy
food. In i-th shop, if Jackie has enough money to buy one unit food in this
shop, he will pay A_{i} to buy it and go to the next shop, otherwise he
will go to the next shop. If he could not buy anything, he will stop shopping.

Now the money in Jackie’s pocket is m, he wants to know the total amount of food he can buy.