Fibonacci subsequence
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Christopher studied sequences and permutations at school today. He really liked the Fibonacci sequence. A sequence of numbers a[1]
, a[2]
, ... is Fibonacci, if for any i > 2 it is true that a[i]
= a[i-1]
+ a[i-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 10^9
.
Output
Print "YES" without quotes if the numbers can be used to form a Fibonacci sequence, otherwise print "NO".
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 34%