eolymp
bolt
Try our new interface for solving problems
Problems

Fibonacci sequence

Fibonacci sequence

Time limit 4 seconds
Memory limit 256 MiB

A set of distinct integers is given. Find the length of the longest sequence of Fibonacci numbers that can be arranged from them. Each number can be used in the sequence no more than once. The sequence F is called the Fibonacci sequence, if

F[1] = a

F[2] = b

F[i] = F[i–2] + F[i–1]

Input data

The first line contains the number n (2n10000) of elements in the set. The second line contains n distinct integers a[i] (1a[i]10^9).

Output data

Print the length of the longest Fibonacci sequence, that can be created from given numbers.

Examples

Input example #1
6
2 3 4 5 6 9
Output example #1
3
Author A.Milanin
Source ACM, Ukraine, First Stage, 09.04.2011