#B4290. Unreachable Tangyuan Count
Unreachable Tangyuan Count
Unreachable Tangyuan Count
A vendor sells tangyuan (glutinous rice balls) in pre-packaged sizes. In particular, the vendor offers exactly different packet sizes. However, not every quantity of tangyuan is available for purchase because the tangyuan can only be bought in multiples of one of these packet sizes. For example, if and the packets contain and tangyuan respectively, the buyer cannot purchase exactly , , , or tangyuan.
Given an integer and the packet sizes, determine the number of different totals (i.e. quantities of tangyuan) that cannot be obtained by any nonnegative combination of the given packet sizes. If there exist infinitely many unattainable quantities, output .
Note: It is guaranteed that if the greatest common divisor of the packet sizes (denoted by ) is not , then there are infinitely many unreachable quantities.
inputFormat
The input consists of two lines:
- The first line contains an integer representing the number of packet sizes.
- The second line contains space-separated integers, each representing a packet size.
outputFormat
Output a single integer: the number of unattainable tangyuan quantities. If there are infinitely many unattainable totals, print .
sample
2
3 5
4