P8646 [Lanqiao Cup 2017 NOI Qualifier AB] Baozi Combination Counting
Description
Xiaoming eats breakfast at a baozi shop almost every morning. He found that the shop has $N$ types of steamers. The $i$-th type of steamer can hold exactly $A_i$ baozi. There are many steamers of each type, which can be considered unlimited.
Whenever a customer wants to buy $X$ baozi, the seller will quickly choose some steamers so that the total number of baozi in these steamers is exactly $X$. For example, there are $3$ types of steamers that can hold $3$, $4$, and $5$ baozi. When a customer wants to buy $11$ baozi, the seller will choose $2$ steamers of $3$ plus $1$ steamer of $5$ (or he may choose $1$ steamer of $3$ plus $2$ steamers of $4$).
Of course, sometimes the seller cannot make up the number the customer wants, no matter what. For example, there are $3$ types of steamers that can hold $4$, $5$, and $6$ baozi. When a customer wants to buy $7$ baozi, the seller cannot make it.
Xiaoming wants to know how many amounts cannot be made up by the seller.
Input Format
The first line contains an integer $N$. $(1 \le N \le 100)$.
The next $N$ lines each contain an integer $A_i$. $(1 \le A_i \le 100)$.
Output Format
Output an integer as the answer. If there are infinitely many amounts that cannot be made up, output `INF`.
Explanation/Hint
For sample $1$, the amounts that cannot be made up include: $1,2,3,6,7,11$.
For sample $2$, all odd numbers cannot be made up, so there are infinitely many.
Lanqiao Cup 2017 Provincial Contest, Group A, Problem H.
Translated by ChatGPT 5