Greedy Coin Exchange

Given sorted coin denominations starting with 1, decide whether the greedy largest-coin-first method always uses the fewest coins for every amount.

Medium7GreedyDynamic programmingNumber theoryMathNo attempts yetTime limit1sMemory limit64 MB

Problem

The coin change problem is a standard first example of dynamic programming. It reads as follows.

  • To make change for CC won with coins of denominations P1,P2,,PNP_1, P_2, \dots, P_N, what is the smallest number of coins needed?

Byeongchan wants to solve it with a simple method. His method is as follows.

  • At each step, add one coin of the largest denomination that does not exceed the amount still missing. Repeat until the remaining amount is 0.

Byeongchan's method is not always optimal. To make 8 won from coins of 1, 4, and 6, his method uses one 6 and two 1s, three coins in total. Two 4s do it with two coins.

Byeongchan realized that his method works for some sets of denominations and fails for others. Given the denominations, write a program that decides whether his method produces the smallest number of coins for every CC.

Input

The first line contains the number of denominations NN. (1N1001 \le N \le 100)

The second line contains the denominations P1,P2,,PNP_1, P_2, \dots, P_N separated by spaces. They satisfy 1=P1<P2<<PN1000001 = P_1 < P_2 < \dots < P_N \le 100000.

Output

Print Yes if Byeongchan's method is always optimal, and No otherwise.