Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 
 1.  the sequence consists of at least two elements 1.  *f*<sub class="lower-index">0</sub> and *f*<sub class="lower-index">1</sub> are arbitrary 1.  *f*<sub class="lower-index">*n* + 2</sub> = *f*<sub class="lower-index">*n* + 1</sub> + *f*<sub class="lower-index">*n*</sub> for all *n* ≥ 0. 
You are given some sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. Your task is rearrange elements of this sequence in such a way that its longest possible prefix is Fibonacci-ish sequence.
The first line of the input contains a single integer *n* (2 ≤ *n* ≤ 1000) — the length of the sequence *a*<sub class="lower-index">*i*</sub>.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (|*a*<sub class="lower-index">*i*</sub>| ≤ 10<sup class="upper-index">9</sup>).
In the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence *a*<sub class="lower-index">*i*</sub> would be Fibonacci-ish.

In the second sample, the optimal way to rearrange elements is <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/16f1f7e35511b29cb1396890ca2fb7dfa4d428de.png" style="max-width: 100.0%;max-height: 100.0%;"/>, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/4003973f16750522e492d7d79318d7e2f0ff99cd.png" style="max-width: 100.0%;max-height: 100.0%;"/>, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/87b18fd9524b11e12faf154302fb14c1b55556fb.png" style="max-width: 100.0%;max-height: 100.0%;"/>, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b8950ea952476baea26e03281fa2f7640b6241ef.png" style="max-width: 100.0%;max-height: 100.0%;"/>, 28.
3
1 2 -1
3
5
28 35 7 14 21
4
11
-9 -1 -10 9 7 -4 0 -8 -3 3 5
5
10
-4 -8 -8 8 -9 0 -7 9 1 0
4
2
2 2
2
4
1 -1 0 -2
4
2
1000000000 1000000000
2
3
1 1 2
3
5
0 0 0 0 0
5
6
1 -1 0 -1 -1 -2
6
5
-7 0 -7 -7 -14
5
3
0 -44 -49
2
5
-1 1 0 0 0
3
2
0 0
2
3
0 0 0
3
4
0 0 0 0
4
5
0 0 0 0 0
5
10
0 0 0 0 0 0 0 0 0 0
10
import random, math
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right
from collections import Counter


# Function to call the actual solution
def solution(li):
	ma = Counter(li)
	ans = 0
	for i in range(len(li)):
		for j in range(len(li)):
			if i != j:
				f0 = li[i]
				f1 = li[j]
				if f0 == 0 and f1 == 0:
					ans = max(ans, ma[0]-2)
				ma[f0] -= 1
				ma[f1] -= 1
				cur = 2
				while True:
					nxt = f0 + f1
					if nxt in ma and ma[nxt] > 0:
						f0 = f1 + 1 - 1
						f1 = nxt + 1 - 1
						ma[nxt] -= 1
						cur += 1
					else:
						break
				cur1 = 2
				ma[f0] += 1
				ma[f1] += 1
				while cur1 < cur:
					prev = f1 - f0
					f1 = f0 + 1 - 1
					f0 = prev + 1 - 1
					ma[prev] += 1
					cur1 += 1
				ans = max(ans, cur)
	return ans
# Function to take input
def input_test():
	# for _ in range(int(input())):
		n = int(input())
		# a, b = map(int, input().strip().split(" "))
		# a, b, c = map(int, input().strip().split(" "))
		li = list(map(int, input().strip().split(" ")))
		out = solution(li)
		print(out)

# Function to check test my code
def test():
	pass


input_test()
# test()