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
n = int(input())
a = list(map(int,input().split()))
s = {}			#dic
d = {}			#dic
p = set()		#set
mx = - 10**15
mi = -mx
ans = 2
for i in range(n) :
	if a[i] in s :
		s[a[i]] += 1
	else :
		s[a[i]] = 0
	mx = max(mx,a[i])
	mi = min(mi,a[i])
if 0 in s : ans = max(ans,s[0])
for i in range(n) :
	for j in range(n) :
		if (j==i) or (a[i]==0 and a[j]==0) or ((a[i], a[j]) in p) : continue
		f0 = a[i]; f1 = a[j]; ansi = 2; f2 = 0;
		d = {}
		p.add((a[i], a[j]))
		while True :
			f2 = f1 + f0
			f0 = f1
			f1 = f2
			if (f2 > mx) or (f2 < mi) : break
			if f2 in s :
				d[f2] = s[f2]
			else : break
		f0 = a[i]; f1 = a[j];
		if f1==f0 :
			d[f0] = s[f0] - 2
		else :
			d[f0] = s[f0] - 1
			d[f1] = s[f1] - 1
		while True :
			f2 = f1 + f0
			f0 = f1
			f1 = f2
			if (f2 > mx) or (f2 < mi) : break
			if f2 in d :
				ansi += 1
				d[f2] -= 1
			else : break
		ans = max(ans, ansi)
print(ans)

