There are two merchants in the market. Initially, the first merchant has
items for sale at distinct prices and the second merchant has items for sale at distinct prices.
If you buy an item from a merchant, the prices of all remaining items for both merchants change in the following manner:
- The cost of all the remaining items of the chosen merchant will increase by
- .
Note that prices may become negative during this process.
For e.g. if
and you buy the second item from the second merchant then the prices of remaining items will be as followsYou can only buy an item if its cost is at most
. Can you buy all items from both merchants in the market in some order?
Input Format
- The first line of the input contains a single integer
- - the prices of items of second merchant.
Output Format
For each test case, output Yes
if it is possible to buy all items from both merchants in the market in some order. Otherwise, output No
.
You may print each character of Yes
and No
in uppercase or lowercase (for example, the strings yEs
, yes
, Yes
and YES
will all be treated as identical).
Constraints
Sample Input 1
6
1 2 1
1
1 2
2 1 2
1 2
1
3 2 5
1 2 4
4 9
3 3 7
2 4 8
1 4 8
5 10 27
3 6 17 28 30
1 3 4 5 7 9 21 27 29 30
9 4 21
1 5 6 8 14 16 19 22 25
2 9 23 27
Sample Output 1
YES
YES
NO
YES
YES
NO
Explanation
Test case 1: One possible sequence of operations is shown below. The item we purchase in a given turn is highlighted in red.
Test case 2: One possible sequence of operations is shown below. The item we purchase in a given turn is highlighted in red.
Note that prices may become
during this process and in such a case the item can still be bought.
Test case 3: It can be shown that there is no way to buy the second item sold by Merchant
regardless of the order in which we buy the items.
Test case 4: One possible sequence of operations is shown below. The item we purchase in a given turn is highlighted in red.
ConversionConversion EmoticonEmoticon