#D13177. Slimming Plan
Slimming Plan
Slimming Plan
Chokudai loves eating so much. However, his doctor Akensho told him that he was overweight, so he finally decided to lose his weight.
Chokudai made a slimming plan of a -day cycle. It is represented by integers . His weight is on the 0-th day of the plan and he aims to reduce it to (). If his weight on the -th day of the plan is , it will be on the -th day. Note that is the remainder obtained by dividing by . If his weight successfully gets less than or equal to , he will stop slimming immediately.
If his slimming plan takes too many days or even does not end forever, he should reconsider it.
Determine whether it ends or not, and report how many days it takes if it ends.
Input
The input consists of a single test case formatted as follows.
The first line consists of three integers , , (). The second line consists of integers ( for each ).
Output
If Chokudai's slimming plan ends on the -th day, print in one line. If it never ends, print .
Examples
Input
65 60 3 -2 3 -4
Output
4
Input
65 60 3 -2 10 -3
Output
-1
Input
100000 1 1 -1
Output
99999
Input
60 59 1 -123
Output
1
inputFormat
Input
The input consists of a single test case formatted as follows.
The first line consists of three integers , , (). The second line consists of integers ( for each ).
outputFormat
Output
If Chokudai's slimming plan ends on the -th day, print in one line. If it never ends, print .
Examples
Input
65 60 3 -2 3 -4
Output
4
Input
65 60 3 -2 10 -3
Output
-1
Input
100000 1 1 -1
Output
99999
Input
60 59 1 -123
Output
1
样例
100000 1 1
-1
99999