atcoder#ABC182F. [ABC182F] Valid payments
[ABC182F] Valid payments
Score : points
Problem Statement
In Republic of AtCoder, kinds of coins are used: -yen, -yen, -yen, , -yen coins. Here, holds, and for each such that , holds and is a multiple of .
At some shop in this country, Lunlun the dog bought an -yen product by giving yen to the clerk and receiving the change of yen from the clerk. (The change may have been yen.) Here, both Lunlun and the clerk used the minimum number of coins needed to represent those amounts of money. Additionally, the clerk did not return any kind of coins that Lunlun gave him.
Given , find the number of possible values for .
Constraints
- $1 = A_1 \lt A_2 \lt A_3 \lt \dots \lt A_N \le 10^{15}$
- is a multiple of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
$A_1 \hspace{7pt} A_2 \hspace{7pt} A_3 \hspace{5pt} \dots\ \hspace{5pt} A_N$
Output
Print the number of possible values for .
3 9
1 5 10
3
can be , , or . For example, when , Lunlun gives one -yen coin and four -yen coins, and the clerk returns one -yen coin. Here, the clerk is not returning any kind of coins that Lunlun gives him, satisfying the requirement.
5 198
1 5 10 50 100
5
can be , , , , or .
4 44
1 4 20 100
4
can be , , , or .
9 11837029798
1 942454037 2827362111 19791534777 257289952101 771869856303 3859349281515 30874794252120 216123559764840
21