Fibonacci subsequence
Fibonacci subsequence
Christopher studied sequences and permutations at school today. He really liked the Fibonacci sequence. A sequence of numbers a1
, a2
, ... is Fibonacci, if for any i > 2 it is true that ai
= ai-1
+ ai-2
.
In the evening Christopher came to visit Rabbit and saw a set of cards with numbers on his table. Christopher was immediately interested in the question - is it possible to compose a Fibonacci sequence from these numbers.
Input
The first line contains the number n (1 ≤ n ≤ 100) of elements in the sequence. The second line contains n positive integers less than 109
.
Output
Print "YES" without quotes if the numbers can be used to form a Fibonacci sequence, otherwise print "NO".
3 5 8 3
YES
Example description: The sequence must be monotonically non-decreasing