#P9412. 「NnOI R1-T1」购物
「NnOI R1-T1」购物
Problem Description
Little R is a girl who likes shopping. She lives in the country OAI.
There are kinds of coin denominations in OAI. Their values are , and they satisfy that is a multiple of . In OAI, the only payment method is coins.
Shops in OAI do not support making change. When she shops, she must pay with coins whose total value is exactly equal to the price. For the same price, there can be different payment methods. For example, if the coin denominations in OAI are yuan and yuan, then paying yuan has two methods: pay coins of yuan, or pay coin of yuan and coins of yuan.
Since the coins have roughly the same weight, she does not want to carry coins that are too heavy, so for each purchase she will carry as few coins as possible while meeting the requirement. She discovered a magical phenomenon: sometimes buying an item that costs yuan more can make her carry many fewer coins.
Can you find the smallest such that buying an item costing yuan requires fewer coins than buying an item costing yuan?
Input Format
The first line contains an integer , indicating the number of coin denominations.
The second line contains integers. The -th integer is , indicating the value of the -th coin denomination.
Output Format
One line containing one integer , which is the answer. In particular, if no such exists, output .
4
1 6 12 48
6
3
1 2 8
8
1
1
-1
Hint
Sample Explanation
For sample , buying items costing yuan requires coins of yuan respectively, while buying an item costing yuan only requires coin of yuan.
For sample , buying an item costing yuan or yuan both requires coin, which does not satisfy the requirement that the number of coins needed is fewer.
Constraints
For of the testdata, , , and is a multiple of .
Hint: This problem uses bundled tests.
This problem has subtasks.
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| None | 20 | ||
| Guaranteed | |||
| Guaranteed to have a solution | 30 | ||
| None |
Source
| Item | Staff |
|---|---|
| idea | rui_er |
| std | |
| data | |
| check | Kevin0501 |
| solution | rui_er |
Translated by ChatGPT 5