#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
    const char* c = strchr(na + 1, ',');
    cerr.write(na, c - na) << " : " << arg1 << " , ";
    __f(c + 1, args...);
}
#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
    int n;
    cin >> n;
    map <LL,LL> have;
    vector <LL> a (n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        have[a[i]]++;
    }

    int mx_len = 0;
    map <pair <LL,LL>, LL> used_pair;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == j) continue;
            if (used_pair.count({a[i], a[j]})) continue;
            used_pair[{a[i], a[j]}] = 1;
            LL f = a[i], s = a[j];
            if (a[i] == 0 && a[j] == 0) {
                mx_len = max(1LL * mx_len, 1LL * have.count(0LL));
                continue;
            }
            map <LL,LL> used;
            used[a[i]]++;
            used[a[j]]++;
            int cur_len = 2;
            while (1) {
                LL need = f + s;
                if (used[need] < have[need]) {
                    used[need]++;
                    f = s;
                    s = need;
                    cur_len++;
                }
                else {
                    break;
                }
            }
            mx_len = max(mx_len, cur_len);
        }
    }
    cout << mx_len << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    for (int tc = 1; tc <= t; tc++) solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
    const char* c = strchr(na + 1, ',');
    cerr.write(na, c - na) << " : " << arg1 << " , ";
    __f(c + 1, args...);
}
#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
    int n;
    cin >> n;
    map <LL,int> have;
    vector <LL> a (n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        have[a[i]]++;
    }

    int mx_len = 0;
    map <pair <LL,LL>, int> used_pair;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == j) continue;
            if (used_pair.count({a[i], a[j]})) continue;
            used_pair[{a[i], a[j]}] = 1;
            LL f = a[i], s = a[j];
            if (a[i] == 0 && a[j] == 0) {
                mx_len = max(1LL * mx_len, 1LL * have.count(0LL));
                continue;
            }
            map <LL,int> used;
            used[a[i]]++;
            used[a[j]]++;
            int cur_len = 2;
            while (1) {
                LL need = f + s;
                if (have.count(need) && used[need] < have[need]) {
                    used[need]++;
                    f = s;
                    s = need;
                    cur_len++;
                }
                else {
                    break;
                }
            }
            mx_len = max(mx_len, cur_len);
        }
    }
    cout << mx_len << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    for (int tc = 1; tc <= t; tc++) solve();
    return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int aa[N+2];
unordered_map<int,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>aa[i];
    mp[aa[i]]=1;
  }
  sort(aa+1,aa+n+1);int ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      int f0=aa[i],f1=aa[j];
      int cnt=2;
      while(true)
      {
        if(mp[f0+f1])
        {
          cnt++;
          int f=f1+f0;
          f0=f1;f1=f;
        }
        else break;
      }
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int aa[N+2];
map<int,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>aa[i];
    mp[aa[i]]=1;
  }
  sort(aa+1,aa+n+1);int ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      int f0=aa[i],f1=aa[j];
      int cnt=2;
      while(true)
      {
        if(mp[f0+f1])
        {
          cnt++;
          int f=f1+f0;
          f0=f1;f1=f;
        }
        else break;
      }
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int aa[N+2],dp[N+2][N+2];
map<int,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int i=1;i<=n;i++)
    cin>>aa[i];
  sort(aa+1,aa+n+1);
  for(int i=1;i<=n;i++)
    mp[aa[i]]=i;
  int ans=0;memset(dp,-1,sizeof(dp));
  for(int i=n;i>=1;i--)
  {
    for(int j=i-1;j>=1;j--)
    {
      int f0=j,f1=i;
      int cnt=2;
      while(true)
      {
        if(dp[f0][f1]!=-1)
        {
          cnt+=dp[f0][f1]-2;break;
        }
        if(mp[aa[f0]+aa[f1]])
        {
          cnt++;
          int f=mp[aa[f0]+aa[f1]];
          f0=f1;f1=f;
        }
        else break;
      }
      dp[j][i]=cnt;
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int aa[N+2];
map<int,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>aa[i];mp[aa[i]]++;
  }
  sort(aa+1,aa+n+1);int ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      vector<int>v;int cnt=2,f0=aa[i],f1=aa[j];
      mp[f0]--;mp[f1]--;
      v.push_back(f0);v.push_back(f1);
      while(true)
      {
        if(f0==0&&f1==0)
        {
          cnt+=mp[0];break;
        }
        if(mp[f0+f1])
        {
          int f=f0+f1;mp[f]--;
          f0=f1;f1=f;v.push_back(f);
          cnt++;
        }
        else break;
      }
      for(auto x:v)mp[x]++;
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int aa[N+2];
map<int,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>aa[i];mp[aa[i]]++;
  }
  sort(aa+1,aa+n+1);int ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
    {
      if(i==j)continue;
      vector<int>v;int cnt=2,f0=aa[i],f1=aa[j];
      mp[f0]--;mp[f1]--;
      v.push_back(f0);v.push_back(f1);
      while(true)
      {
        if(f0==0&&f1==0)
        {
          cnt+=mp[0];break;
        }
        if(mp[f0+f1])
        {
          int f=f0+f1;mp[f]--;
          f0=f1;f1=f;v.push_back(f);
          cnt++;
        }
        else break;
      }
      for(auto x:v)mp[x]++;
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int aa[N+2],dp[N+2][N+2];
unordered_map<int,int>mp;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int i=1;i<=n;i++)
    cin>>aa[i];
  sort(aa+1,aa+n+1);
  for(int i=1;i<=n;i++)
    mp[aa[i]]=i;
  int ans=0;memset(dp,-1,sizeof(dp));
  for(int i=n;i>=1;i--)
  {
    for(int j=i-1;j>=1;j--)
    {
      int f0=i,f1=j;
      int cnt=2;
      while(true)
      {
        if(dp[f0][f1]!=-1)
        {
          cnt+=dp[f0][f1];break;
        }
        if(mp[aa[f0]+aa[f1]])
        {
          cnt++;
          int f=mp[aa[f0]+aa[f1]];
          f0=f1;f1=f;
        }
        else break;
      }
      dp[i][j]=cnt;
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp;

int main()
{
    ll n,i,j,ara[2000],mx,f1,f2,k,t,cnt=0;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    mx=mp[0];

    ll v[200];

    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            memset(v, 0, sizeof v);

            cnt=0;

            v[0]=ara[i];

            v[1]=ara[j];

            if(v[0] || v[1])
            {
                for(k=2; ; k++)
                {
                    v[k]=v[k-1]+v[k-2];

                    if(abs(v[k])>=10e9)
                    {
                        break;
                    }
                }

            }

            mp[ara[i]]--;

            mp[ara[j]]--;

            for(t=2; t<k; t++)
            {
                if(!mp[v[t]])
                {
                    break;
                }

                else
                {
                    cnt++;
                }
            }

            mx=max(mx,cnt+2);

            mp[ara[i]]++;

            mp[ara[j]]++;

        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp;

int main()
{
    ll n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                pre1=mp[ara[i]],pre2=mp[ara[j]];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    while(abs(temp)<10e9)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0 && abs(temp)<=10e9)
                        {
                            ans++;

                            if(temp==ara[i] || temp==ara[j])
                            {
                                mp[temp]--;
                            }
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                mp[ara[i]]=pre1;

                mp[ara[j]]=pre2;

            }
        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp;

vector < ll > vv;

int main()
{
    ll n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2,t;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    vv.push_back(ara[i]);

                    vv.push_back(ara[j]);

                    while(abs(temp)<=10e9)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0 && abs(temp)<=10e9)
                        {
                            ans++;

                            mp[temp]--;

                            vv.push_back(temp);
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                for(t=0; t<vv.size(); t++)
                {
                    mp[vv[t]]++;
                }

                vv.clear();

            }
        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp;

int main()
{
    ll n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                pre1=mp[ara[i]],pre2=mp[ara[j]];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    while(abs(temp)<10e13)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0 && abs(temp)<=10e13)
                        {
                            ans++;

                            if(temp==ara[i])
                            {
                                mp[temp]--;
                            }
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                mp[ara[i]]=pre1;

                mp[ara[j]]=pre2;

            }
        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp;

int main()
{
    ll n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                pre1=mp[ara[i]],pre2=mp[ara[j]];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    while(abs(temp)<10e9)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0)
                        {
                            ans++;

                            if(temp==ara[i] || temp==ara[j])
                            {
                                mp[temp]--;
                            }
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                mp[ara[i]]=pre1;

                mp[ara[j]]=pre2;

            }
        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp,mp2;

int main()
{
    ll n,i,j,ara[2000],mx,f1,f2,k,t,cnt=0;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    mx=mp[0];

    ll v[200];

    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            memset(v, 0, sizeof v);

            cnt=0;

            v[0]=ara[i];

            v[1]=ara[j];

            if(v[0] || v[1])
            {
                for(k=2; ; k++)
                {
                    v[k]=v[k-1]+v[k-2];

                    if(abs(v[k])>=10e9)
                    {
                        break;
                    }
                }

            }

            mp2=mp;

            for(t=0; t<k; t++)
            {
                if(!mp2[v[t]])
                {
                    break;
                }

                else
                {
                    cnt++;

                    mp2[v[t]]--;
                }
            }

            mx=max(mx,cnt);

        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < int , int > mp;

int main()
{
    int n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                pre1=mp[ara[i]],pre2=mp[ara[j]];

                mp[ara[i]]--;

                mp[ara[j]]--;

                while(abs(temp)<=10e9)
                {
                    temp=f0+f1;

                    if(mp[temp]>0)
                    {
                        ans++;

                        if(temp==ara[i] || temp==ara[j])
                        {
                            mp[temp]--;
                        }
                    }

                    else
                    {
                        break;
                    }

                    f0=f1;

                    f1=temp;
                }

                mx=max(mx,ans);

                mp[ara[i]]=pre1;

                mp[ara[j]]=pre2;

            }
        }
    }

    printf("%d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < int , int > mp;

vector < int > vv;

int main()
{
    ll n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2,t;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    vv.push_back(ara[i]);

                    vv.push_back(ara[j]);

                    while(abs(temp)<=10e9)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0 && abs(temp)<=10e9)
                        {
                            ans++;

                            mp[temp]--;

                            vv.push_back(temp);
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                for(t=0; t<vv.size(); t++)
                {
                    mp[vv[t]]++;
                }

                vv.clear();

            }
        }
    }

    printf("%d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < int , int > mp;

vector < int > vv;

int main()
{
    int n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2,t;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    vv.push_back(ara[i]);

                    vv.push_back(ara[j]);

                    while(abs(temp)<=10e9)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0 && abs(temp)<=10e9)
                        {
                            ans++;

                            mp[temp]--;

                            vv.push_back(temp);
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                for(t=0; t<vv.size(); t++)
                {
                    mp[vv[t]]++;
                }

                vv.clear();

            }
        }
    }

    printf("%d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < int , int > mp;

int main()
{
    int n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                pre1=mp[ara[i]],pre2=mp[ara[j]];

                if(f0==0 && f1==0)
                {
                    ans=mp[0];
                }

                else
                {

                    mp[ara[i]]--;

                    mp[ara[j]]--;

                    while(abs(temp)<=10e9)
                    {
                        temp=f0+f1;

                        if(mp[temp]>0)
                        {
                            ans++;

                            if(temp==ara[i] || temp==ara[j])
                            {
                                mp[temp]--;
                            }
                        }

                        else
                        {
                            break;
                        }

                        f0=f1;

                        f1=temp;
                    }

                }

                mx=max(mx,ans);

                mp[ara[i]]=pre1;

                mp[ara[j]]=pre2;

            }
        }
    }

    printf("%d\n",mx);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int

map < ll , ll > mp;

int main()
{
    ll n,i,j,ara[1500],f0,f1,temp=0,mx=0,ans=0,pre1,pre2;

    scanf("%I64d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);

        mp[ara[i]]++;
    }

    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            ans=2;

            if(i!=j)
            {
                f0=ara[i];

                f1=ara[j];

                pre1=mp[ara[i]],pre2=mp[ara[j]];

                mp[ara[i]]--;

                mp[ara[j]]--;

                while(abs(temp)<=10e9)
                {
                    temp=f0+f1;

                    if(mp[temp]>0)
                    {
                        ans++;

                        if(temp==ara[i] || temp==ara[j])
                        {
                            mp[temp]--;
                        }
                    }

                    else
                    {
                        break;
                    }

                    f0=f1;

                    f1=temp;
                }

                mx=max(mx,ans);

                mp[ara[i]]=pre1;

                mp[ara[j]]=pre2;

            }
        }
    }

    printf("%I64d\n",mx);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[1005];
unordered_map<ll,ll> p;
ll cal(ll x,ll y){
    ll num=2,v=x,t=y;
    p[x]--;p[y]--;
    vector<ll> b;
    while(p[x+y]>0){
        ll c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[v]++;p[t]++;
    return num;
}
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            ans=max(ans,cal(a[i],a[j]));
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[1005];
map<ll,ll> p;
ll cal(ll x,ll y){
    ll num=2;
    p[x]--;p[y]--;
    vector<ll> b;
    while(p[x+y]){
        ll c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[x]++;p[y]++;
    return num;
}
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            ans=max(ans,cal(a[i],a[j]));
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
int a[1005];
unordered_map<int,int> p;
int cal(int x,int y){
    int num=2;
    p[x]--;p[y]--;
    vector<int> b;
    while(max(abs(x),abs(y))<=1e9&&p[x+y]){
        int c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[x]++;p[y]++;
    return num;
}
int main(){
    int n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            ans=max(ans,cal(a[i],a[j]));
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[1005];
unordered_map<ll,ll> p;
map<pair<ll,ll>,ll> vis;
ll cal(ll x,ll y){
    ll num=2,v=x,t=y;
    p[x]--;p[y]--;
    vector<ll> b;
    while(p[x+y]>0){
        ll c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[v]++;p[t]++;
    return num;
}
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j||vis[{a[i],a[j]}]) continue;
            ans=max(ans,cal(a[i],a[j]));vis[{a[i],a[j]}]=1;
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[1005];
unordered_map<ll,ll> p;
unordered_map<pair<ll,ll>,ll> ok;
ll cal(ll x,ll y){
    ll num=2,v=x,t=y;
    p[x]--;p[y]--;
    vector<ll> b;
    while(p[x+y]>0){
        ll c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[v]++;p[t]++;
    return num;
}
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j||vis[{a[i],a[j]}]) continue;
            ans=max(ans,cal(a[i],a[j]));vis[{a[i],a[j]}]=1;
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[1005];
unordered_map<ll,ll> p;
ll cal(ll x,ll y){
    ll num=2;
    p[x]--;p[y]--;
    vector<ll> b;
    while(p[x+y]){
        ll c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[x]++;p[y]++;
    return num;
}
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            ans=max(ans,cal(a[i],a[j]));
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[1005];
unordered_map<ll,ll> p;
ll cal(ll x,ll y){
    ll num=2;
    p[x]--;p[y]--;
    vector<ll> b;
    while(p[x+y]>0){
        ll c=x+y;
        p[c]--;b.push_back(c);
        x=y;y=c;num++;
    }
    for(auto i:b){
        p[i]++;
    }
    p[x]++;p[y]++;
    return num;
}
int main(){
    ll n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);p[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            ans=max(ans,cal(a[i],a[j]));
            if(ans==n) break;
        }
    }
    cout<<ans<<endl;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  set <int> distinct;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    distinct.insert(v[i]);
  }

  int ans = 2;
  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];

      while (1) {
        if (distinct.find(fib[fib.size() - 1] + fib[fib.size() - 2]) == distinct.end()) break;
        fib.pb(fib[fib.size() - 1] + fib[fib.size() - 2]);
      }

      ans = max(ans , (int)fib.size());
    }
  }

  int zero = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) zero++;
  }

  ans = max(ans , zero);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  map <int , int> freq;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    freq[v[i]]++;
  }

  int ans = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) ans++;
  }

  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];
      map <int , int> curFreq = freq;
      curFreq[fib[0]]--, curFreq[fib[1]]--;

      while (1) {
        int cur = fib[fib.size() - 1] + fib[fib.size() - 2];
        if (curFreq.count(cur) == 0) break;
        if (curFreq[cur] > 0) {
          fib.pb(cur);
          curFreq[cur]--;
        }
      }

      ans = max(ans , (int)fib.size());
    }
  }

  ans = max(ans , 2);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  map <int , int> freq;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    freq[v[i]]++;
  }

  int ans = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) ans++;
  }

  map <ii , int> dp;
  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (dp.count({v[i] , v[j]})) continue;
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];

      map <int , int> curFreq;
      curFreq[fib[0]]++, curFreq[fib[1]]++;
      while (1) {
        int cur = fib[fib.size() - 1] + fib[fib.size() - 2];
        int prv = fib[fib.size() - 1], prvOfPrv = fib[fib.size() - 2];
        if (freq.count(cur) == 0) break;
        if (curFreq[cur] + 1 <= freq[cur]) {
          curFreq[cur]++;
          fib.pb(cur);
        } else {
          break;
        }
      }

      dp[{v[i] , v[j]}] = fib.size();

      ans = max(ans , (int)fib.size());
    }
  }

  ans = max(ans , 2);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  map <int , int> freq;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    freq[v[i]]++;
  }

  int ans = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) ans++;
  }

  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];

      map <int , int> curFreq;
      curFreq[fib[0]]++, curFreq[fib[1]]++;
      while (1) {
        int cur = fib[fib.size() - 1] + fib[fib.size() - 2];
        if (freq.count(cur) == 0) break;
        if (curFreq[cur] + 1 <= freq[cur]) {
          curFreq[cur]++;
          fib.pb(cur);
        } else {
          break;
        }
      }

      ans = max(ans , (int)fib.size());
    }
  }

  ans = max(ans , 2);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  set <int> elm;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    elm.insert(v[i]);
  }

  int ans = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) ans++;
  }

  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];

      while (1) {
        int cur = fib[fib.size() - 1] + fib[fib.size() - 2];
        if (elm.find(cur) == elm.end()) break;
        fib.pb(cur);
      }

      ans = max(ans , (int)fib.size());
    }
  }

  ans = max(ans , 2);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  map <int , int> freq;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    freq[v[i]]++;
  }

  int ans = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) ans++;
  }

  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];
      map <int , int> curFreq = freq;
      curFreq[fib[0]]--, curFreq[fib[1]]--;

      while (1) {
        int cur = fib[fib.size() - 1] + fib[fib.size() - 2];
        if (curFreq.count(cur) == 0) break;
        if (curFreq[cur] > 0) {
          fib.pb(cur);
          curFreq[cur]--;
        } else {
          break;
        }
      }

      ans = max(ans , (int)fib.size());
    }
  }

  ans = max(ans , 2);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define vz(x) x.size()
#define deb(x) cerr << " >> " << x << endl
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int INF = 1e9 + 50;
const int MOD = 1e9 + 7;
// #define multipleCaseGETCHAR
// #define multipleCaseSCANF
int n;

void work() {
  in(n);

  vector <int> v(n);
  map <int , int> freq;
  for (int i = 0 ; i < n ; i++) {
    in(v[i]);
    freq[v[i]]++;
  }

  int ans = 0;
  for (int i = 0 ; i < n ; i++) {
    if (v[i] == 0) ans++;
  }

  for (int i = 0 ; i < n ; i++) {
    for (int j = 0 ; j < n ; j++) {
      if (i == j) continue;
      if (v[i] == 0 && v[j] == 0) continue;
      vector <int> fib(2);
      fib[0] = v[i], fib[1] = v[j];
      map <int , int> curFreq = freq;
      curFreq[fib[0]]--, curFreq[fib[1]]--;

      while (1) {
        int cur = fib[fib.size() - 1] + fib[fib.size() - 2];
        if (curFreq.count(cur)) {
          if (curFreq[cur] > 0) {
            fib.pb(cur);
            curFreq[cur]--;
          } else {
            break;
          }
        } else {
          break;
        }
      }

      ans = max(ans , (int)fib.size());
    }
  }

  ans = max(ans , 2);

  printf("%d\n" , ans);
  return;
}

int main() {
  int nQ = 1;
  #ifdef multipleCaseGETCHAR
    in(nQ);
  #endif
  #ifdef multipleCaseSCANF
    scanf("%d" , &nQ);
  #endif
  while (nQ--)
    work();
  return 0;
}

void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if(c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x *= -1;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            while(fre.count(a+b)) {
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    unordered_map<ll,ll> used;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            used.clear();
            used[a]=1;
            used[b]=1;
            while(fre.count(a+b)) {
                int f = ++used[a+b];
                if (f > fre[a+b]) break;
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <unordered_map>
using namespace std;

const int N = 1111;
int a[N];
int n;
int ans = 2;
unordered_map<int, int> b, c;

int solve(int x, int y)
{
	c.clear();
	c[x]++;
	c[y]++;
	int cnt = 2;
	while(true)
	{
		int z = x + y;
		int p = c[z] + 1;
		if (p > b[z]) return cnt;
		x = y;
		y = z;
		c[y] = p;
		cnt++;
	}
	throw;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		b[a[i]]++;
	}
	ans = max(ans, b[0]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j && (a[i] != 0 || a[j] != 0))
				ans = max(ans, solve(a[i], a[j]));
	printf("%d\n", ans);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    unordered_map<ll,ll> used;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            used.clear();
            used[a]=1;
            used[b]=1;
            while(fre.count(a+b)) {
                int f = ++used[a+b];
                if (f > fre[a+b]) break;
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            while(fre.count(a+b)) {
                if (a==0 && fre[b]<=1) break;
                if (b==0 && fre[a]<=1) break;
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            while(fre.count(a+b)) {
                if (a<0&&b<0&&a+b>=0) break;
                if (a>0&&b>0&&a+b<=0) break;
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    unordered_map<ll,ll> used;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            used.clear();
            used[a]=1;
            used[b]=1;
            while(fre.count(a+b)) {
                int f = ++used[a+b];
                if (f > fre[a+b]) break;
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    unordered_map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            dis.insert(vi[i]-vi[j]);
        }
    }
    ll ans=0;
    for(auto& d : dis) {
        if (d==0) continue;
        for(int i=0;i<n;i++) {
            ll cnt=2;
            ll a=vi[i];
            ll b;
            if (fre.count(a+d)) {
                b=a+d;
            } else continue;
            while(fre.count(a+b)) {
                cnt++;
                ll t=a;
                a=b;
                b = t + b;
            }
            if (cnt>2) ans=max(ans, cnt);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            while(fre.count(a+b)) {
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            if(cnt>2) ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    ll ans=0;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            ll a=vi[i], b=vi[j];
            if(a==0&&b==0)continue;
            ll cnt=2;
            map<ll,ll> used;
            used[a]=1;
            used[b]=1;
            while(fre.count(a+b)) {
                int f = ++used[a+b];
                if (f > fre[a+b]) break;
                cnt++;
                ll t=a;
                a=b;
                b+=t;
            }
            ans=max(cnt,ans);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using PII = pair<int,int>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repe(i, a, b) for (int i = a; i <= b; i++)
#define irep(i, x) for (auto i = x.begin(); i != x.end(); i++)
#define ALL(x) (x).begin(), (x).end()
const ll mod=1e9+7;
ll pow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void fastio() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);}
const int N = 1e5+10;

void solve() {
    int n;cin>>n;
    vector<ll>vi;
    unordered_set<ll> dis;
    map<ll,ll>fre;
    rep(i,0,n) {
        ll a;cin>>a;vi.push_back(a);
        fre[a]++;
    }
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            dis.insert(vi[i]-vi[j]);
        }
    }
    ll ans=0;
    for(auto& d : dis) {
        if (d==0) continue;
        for(int i=0;i<n;i++) {
            ll cnt=2;
            ll a=vi[i];
            ll b;
            if (fre.count(a+d)) {
                b=a+d;
            } else continue;
            while(fre.count(a+b)) {
                cnt++;
                ll t=a;
                a=b;
                b = t + b;
            }
            if (cnt>2) ans=max(ans, cnt);
        }
    }
    ans=max(ans, fre[0]);
    cout<<ans<<endl;
}

int main() {
    fastio();
    solve();
}


#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll a[1005];
map<pll,ll> ret;
map<ll,ll> cnt;
map<ll,ll> cur;
ll solve(ll x,ll y,ll mx,ll mn)
{
	if((x>mx and y>mx) or (x<mn and y<mn))
	if(ret[{x,y}])
	return ret[{x,y}];

	ret[{x,y}]=2;

	ll req=x+y;

	cur[y]++;

	if(cur[req]<cnt[req])
	ret[{x,y}]+=solve(y,req,max(mx,x),min(mn,x))-1;

	cur[y]--;

	return ret[{x,y}];

}
int main()
{
	is(n);

	up(0,n,i)
	{
		is(a[i]);

		cnt[a[i]]++;
	}

	up(0,n,i)
	up(0,n,j)
	if(i!=j and (a[i]!=0 or a[j]!=0))
	cur[a[i]]++,maxm=max(maxm,solve(a[i],a[j],-inf,inf)),cur[a[i]]--;

	maxm=max(maxm,cnt[0]);

	pp(maxm);
}


#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll a[1005];
map<pll,ll> ret;
map<ll,ll> cnt;
map<ll,ll> cur;
ll solve(ll x,ll y,ll mx,ll mn)
{
	if((x>mx and y>mx) or (x<mn and y<mn))
	if(ret[{x,y}])
	return ret[{x,y}];

	ret[{x,y}]=2;

	ll req=x+y;

	cur[y]++;

	if(cur[req]<cnt[req])
	ret[{x,y}]+=solve(y,req,max(mx,x),min(mn,x))-1;

	cur[y]--;

	return ret[{x,y}];

}
int main()
{
	is(n);

	up(0,n,i)
	{
		is(a[i]);

		cnt[a[i]]++;
	}

	up(0,n,i)
	up(0,n,j)
	if(i!=j and (a[i]!=0 or a[j]!=0))
	cur[a[i]]++,maxm=max(maxm,solve(a[i],a[j],x,x)),cur[a[i]]--;

	maxm=max(maxm,cnt[0]);

	pp(maxm);
}


#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll a[1005];
map<pll,ll> ret;
map<ll,ll> cnt;
map<ll,ll> cur;
ll solve(ll x,ll y,ll mx,ll mn)
{
	if((x>mx and y>0) or (x<mn and y<0))
	if(ret[{x,y}])
	return ret[{x,y}];

	ret[{x,y}]=2;

	ll req=x+y;

	cur[y]++;

	if(cur[req]<cnt[req])
	ret[{x,y}]+=solve(y,req,max(mx,x),min(mn,x))-1;

	cur[y]--;

	return ret[{x,y}];

}
int main()
{
	is(n);

	up(0,n,i)
	{
		is(a[i]);

		cnt[a[i]]++;
	}

	up(0,n,i)
	up(0,n,j)
	if(i!=j and (a[i]!=0 or a[j]!=0))
	cur[a[i]]++,maxm=max(maxm,solve(a[i],a[j],-inf,inf)),cur[a[i]]--;

	maxm=max(maxm,cnt[0]);

	pp(maxm);
}


#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll a[1005];
ll vis[1005][3][1005][3];
map<ll,ll> cnt;
map<ll,ll> cur;
map<ll,ll> p;
ll solve(ll x,ll y)
{

	if(vis[x][cur[a[x]]][y][cur[a[y]]])
	return vis[x][cur[a[x]]][y][cur[a[y]]];

	ll ret=2;

	ll req=a[x]+a[y];

	cur[a[y]]++;

	if(p.find(req)!= p.end() and cur[req]<cnt[req])
	ret+=solve(y,p[req])-1;

	cur[a[y]]--;

	return vis[x][cur[a[x]]][y][cur[a[y]]]=ret;

}
int main()
{
	is(n);

	up(0,n,i)
	{
		is(a[i]);

		p[a[i]]=i;

		cnt[a[i]]++;
	}

	up(0,n,i)
	up(0,n,j)
	if(i!=j and (a[i]!=0 or a[j]!=0))
	cur[a[i]]++,maxm=max(maxm,solve(p[a[i]],p[a[j]])),cur[a[i]]--;

	maxm=max(maxm,cnt[0]);

	pp(maxm);
}


#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll a[1005];
ll vis[1005][5][1005][5];
map<ll,ll> cnt;
map<ll,ll> cur;
map<ll,ll> p;
ll solve(ll x,ll y)
{

	if(vis[x][cur[a[x]]][y][cur[a[y]]])
	return vis[x][cur[a[x]]][y][cur[a[y]]];

	ll ret=2;

	ll req=a[x]+a[y];

	cur[a[y]]++;

	if(p.find(req)!= p.end() and cur[req]<cnt[req])
	ret+=solve(y,p[req])-1;

	cur[a[y]]--;

	return vis[x][cur[a[x]]][y][cur[a[y]]]=ret;

}
int main()
{
	is(n);

	up(0,n,i)
	{
		is(a[i]);

		p[a[i]]=i;

		cnt[a[i]]++;
	}

	up(0,n,i)
	up(0,n,j)
	if(i!=j and (a[i]!=0 or a[j]!=0))
	cur[a[i]]++,maxm=max(maxm,solve(p[a[i]],p[a[j]])),cur[a[i]]--;

	maxm=max(maxm,cnt[0]);

	pp(maxm);
}


#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll a[1005];
ll vis[1005][1005];
map<ll,vector<ll> > p;
map<ll,ll> cur;
ll solve(ll x,ll y)
{
	if(vis[x][y])
	return vis[x][y];

	vis[x][y]=2,cur[a[y]]++;

	ll req=a[x]+a[y];

	if(p.find(req)!= p.end() and cur[req]<p[req].size())
	vis[x][y]+=solve(y,p[req][cur[req]])-1;

	cur[a[y]]--;

	return vis[x][y];

}
int main()
{
	is(n);

	up(0,n,i)
	{
		is(a[i]);

		p[a[i]].pb(i);
	}

	up(0,n,i)
	up(0,n,j)
	if(i!=j)
	cur[a[i]]++,maxm=max(maxm,solve(i,j)),cur[a[i]]--;

	pp(maxm);
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------

void solve()
{
    unordered_map<ll, int> m;
    int n;
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
   // sort(all(v));
    ll cnt=0;
    forn(i,0,n-1)
    {
        forn(j,i+1,n)
        {
            ll a1=v[j], r=2,x=0, a0=v[i];
            unordered_map<ll,int> d;
            while(x<n)
            {
                ll f=a1+a0;
                d[f]++;
                if(d[f]<=m[f])
                {
                    r++;
                    a0=a1;
                    a1=f;
                    x++;
                }
                else
                break;
            }
            cnt=max(cnt, r);
        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------
map<ll, int> m, dum;
int n;
void solve()
{
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
    sort(all(v));
    ll cnt=0;
    forn(i,0,n-1)
    {
        ll a0=v[i];
        forn(j,i+1,n)
        {
            ll a1=v[j], r=2;
            dum.clear();
            dum=m;
            dum[a0]--;
            dum[a1]--;
            while(true)
            {
                ll f=a1+a0;
                if(dum.find(f)!=dum.end() && dum[f]>0)
                {
                    dum[f]--;
                    a0=a1;
                    a1=f;
                    r++;
                }
                else
                break;
            }
            cnt=max(cnt, r);
        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int

using namespace std;
const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<int,int>&p1, const pair<int,int> &p2)const{
            return p1.first < p2.first;

    }
};
// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%60;
    if(k%2) y = (y*x)%60;
    return y;
}
ll match(vll &v, vll &fi)
{
    ll dp[v.size()+1][fi.size()+1]={0};
    int i,j, m=v.size(), n=fi.size();
    for (i = 0; i <= m; i++)
        {
            for (j = 0; j <= n; j++)
            {
                if (i == 0 || j == 0)
                    dp[i][j] = 0;

                else if (v[i - 1] == fi[j - 1])
                    dp[i][j] = dp[i - 1][j - 1] + 1;

                else
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }

        return dp[v.size()][fi.size()];

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
   // cin>>test;
    forn(tes, 0, test)
    {
        ll n, ans=0;
        cin>>n;
        vll v(n);
        forn(i,0,n) cin>>v[i];
        vector<vector<ll>> fi(n-1);
        sort(all(v));
        forn(i,0,n-1)
        {
            ll cnt=2;
            fi.clear();
            fi[i].pb(v[i]);
            fi[i].pb(v[i+1]);
            while(fi[i][cnt-1]<=v[n-1])
            {
                fi[i].pb(fi[i][cnt-1]+fi[i][cnt-2]);
                cnt++;
            }
        }
        forn(i,0,n-1)
        {
            ans=max(ans, match(v, fi[i]));
        }
        cout<<ans<<"\n";

    }

}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------

void solve()
{
    unordered_map<ll, int> m;
    int n;
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
   // sort(all(v));
    ll cnt=0;
    forn(i,0,n)
    {
        forn(j,0,n)
        {
            if(i==j) continue;
            ll a1=v[j], r=2,x=0, a0=v[i];
            if(a1==0 && a0==0)
            {
                cnt = max(cnt, (ll)m[0]);
                continue;
            }
            unordered_map<ll,int> d;
            d[a1]++;
            d[a0]++;

            while(x<n)
            {
                ll f=a1+a0;
                d[f]++;
                if(d[f]<=m[f])
                {
                    r++;
                    a0=a1;
                    a1=f;
                    x++;
                }
                else
                break;
            }
            cnt=max(cnt, r);

        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------

void solve()
{
    unordered_map<ll, int> m;
    int n;
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
   // sort(all(v));
    ll cnt=0;
    forn(i,0,n)
    {
        forn(j,0,n)
        {
            if(i==j) continue;
            ll a1=v[j], r=2,x=0, a0=v[i];
            unordered_map<ll,int> d;
            while(x<n)
            {
                ll f=a1+a0;
                d[f]++;
                if(d[f]<=m[f])
                {
                    r++;
                    a0=a1;
                    a1=f;
                    x++;
                }
                else
                break;
            }
            cnt=max(cnt, r);

        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int

using namespace std;
const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<int,int>&p1, const pair<int,int> &p2)const{
            return p1.first < p2.first;

    }
};
// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%60;
    if(k%2) y = (y*x)%60;
    return y;
}
int match(vi &v, vi &fi)
{
    int dp[v.size()+1][fi.size()+1]={0};
    int i,j, m=v.size(), n=fi.size();
    for (i = 0; i <= m; i++)
        {
            for (j = 0; j <= n; j++)
            {
                if (i == 0 || j == 0)
                    dp[i][j] = 0;

                else if (v[i - 1] == fi[j - 1])
                    dp[i][j] = dp[i - 1][j - 1] + 1;

                else
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }

        return dp[v.size()][fi.size()];

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
   // cin>>test;
    forn(tes, 0, test)
    {
        int n, ans=0;
        cin>>n;
        vi v(n);
        forn(i,0,n) cin>>v[i];
        vi fi;
        sort(all(v));
        forn(i,0,n-1)
        {
            ll cnt=2;
            fi.clear();
            fi.pb(v[i]);
            fi.pb(v[i+1]);
            while(fi[cnt-1]<=v[n-1])
            {
                fi.pb(fi[cnt-1]+fi[cnt-2]);
                cnt++;
            }
            ans=max(ans, match(v, fi));
        }
        cout<<ans<<"\n";

    }

}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------

void solve()
{
    unordered_map<ll, int> m;
    int n;
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
   // sort(all(v));
    ll cnt=0;
    forn(i,0,n-1)
    {
        ll a0=v[i];
        forn(j,i+1,n)
        {
            ll a1=v[j], r=2,x=0;
            unordered_map<ll,int> d;
            while(x<n)
            {
                ll f=a1+a0;
                d[f]++;
                if(d[f]<=m[f])
                {
                    r++;
                    a0=a1;
                    a1=f;
                    x++;
                }
                else
                break;
            }
            cnt=max(cnt, r);
        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------

void solve()
{
    unordered_map<ll, int> m;
    int n;
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
   // sort(all(v));
    ll cnt=0;
    map<pair<ll,ll>, bool> used;
    forn(i,0,n)
    {
        forn(j,0,n)
        {
            if(i==j) continue;
            ll a1=v[j], r=2,x=0, a0=v[i];
            if(used[{a0,a1}])
            continue;
            used[{a0,a1}]=true;
            if(a1==0 && a0==0)
            {
                cnt = max(cnt, (ll)m[0]);
                continue;
            }
            unordered_map<ll,int> d;
            d[a1]++;
            d[a0]++;

            while(x<n)
            {
                ll f=a1+a0;
                d[f]++;
                if(d[f]<=m[f])
                {
                    r++;
                    a0=a1;
                    a1=f;
                    x++;
                }
                else
                break;
            }
            cnt=max(cnt, r);

        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define forn(i, s, n)  for(int i=(int)s; i<int(n); i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define ull unsigned long long int
#define prec(n) fixed<<setprecision(n)
#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); itval(_it, args); }
using namespace std;

void itval(istream_iterator<string> it) {}
template<typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}

template <typename T>
inline void print(T x){cout<<x<<"\n";}

// -----------------------------------------------------------------------

const ll MOD = 1e9+7;
struct custom{
    bool operator()(const pair<ll,ll>&p1, const pair<ll,ll> &p2)const{
            if(p1.first==p2.first)
            {
                return p1.second < p2.second;
            }
            return p1.first > p2.first;

    }
};

// Calculate x^k % MOD -------------------------------------------------
ll get_pow(ll x, ll k)
{
    if(k==0) return 1ll;
    ll y = get_pow(x, k/2);
    y = (y*y)%MOD;
    if(k%2) y = (y*x)%MOD;
    return y;
}

// ---------------------------------------------------------------------

void solve()
{
    unordered_map<ll, int> m;
    int n;
    cin>>n;
    vll v(n);
    forn(i,0,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
   // sort(all(v));
    ll cnt=0;
    forn(i,0,n)
    {
        forn(j,0,n)
        {
            if(i==j) continue;
            ll a1=v[j], r=2,x=0, a0=v[i];
            unordered_map<ll,int> d;
            d[a1]++;
            d[a0]++;
            while(x<n)
            {
                ll f=a1+a0;
                d[f]++;
                if(d[f]<=m[f])
                {
                    r++;
                    a0=a1;
                    a1=f;
                    x++;
                }
                else
                break;
            }
            cnt=max(cnt, r);

        }
    }
    print(cnt);
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    forn(tes, 0, test)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    map <ll,ll> mp;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans = max(2LL,mp[0]);

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i==j)continue;
            if(a[i]==0 && a[j]==0)continue;

            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            mp[t1]--;
            mp[t2]--;

            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            //cout<<t1<<"\n"<<t2<<"\n";
            while(mp.find(t1+t2)!=mp.end() && mp[t1+t2]>0)
            {
              //  cout<<t1+t2<<"\n";
                len++;
                tmp.pb(t1+t2);
                mp[t1+t2]--;
                swap(t1,t2);
                t2 += t1;
            }
            //cout<<len<<"\n";
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                mp[tmp[k]]++;
            //break;
        }
        //break;
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    multiset <ll> ms;
    ll a[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ms.insert(a[i]);
    }
    ll x = ms.count(0);
    ll ans = max(2LL,x);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n,i!=j;j++)
        {
            if(a[i]==0 && a[j]==0)continue;
            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            ms.erase(ms.find(t1));
            ms.erase(ms.find(t2));
            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            while(!ms.empty() && ms.find(t1+t2)!=ms.end())
            {
                len++;
                tmp.pb(t1+t2);
                ms.erase(ms.find(t1+t2));
                ll p = t1+t2;
                t1 = t2;
                t2 = p;
            }
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                ms.insert(tmp[k]);
        }
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    multiset <ll> ms;
    ll a[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ms.insert(a[i]);
    }

    ll ans = max(2LL,ms.count(0));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n,i!=j;j++)
        {
            if(a[i]==0 && a[j]==0)continue;
            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            while(!ms.empty() && ms.find(t1+t2)!=ms.end())
            {
                len++;
                tmp.pb(t1+t2);
                ms.erase(t1+t2);
                swap(t1,t2);
                t2+=t1;
            }
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                ms.insert(tmp[k]);
        }
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    multiset <ll> ms;
    ll a[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ms.insert(a[i]);
    }
    ll x = ms.count(0);
    ll ans = max(2LL,x);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n,i!=j;j++)
        {
            if(a[i]==0 && a[j]==0)continue;
            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            ms.erase(t1);
            ms.erase(t2);
            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            while(!ms.empty() && ms.find(t1+t2)!=ms.end())
            {
                len++;
                tmp.pb(t1+t2);
                ms.erase(t1+t2);
                swap(t1,t2);
                t2+=t1;
            }
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                ms.insert(tmp[k]);
        }
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    multiset <ll> ms;
    ll a[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ms.insert(a[i]);
    }
    ll x = ms.count(0);
    ll ans = max(2LL,x);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n,i!=j;j++)
        {
            if(a[i]==0 && a[j]==0)continue;
            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            ms.erase(ms.find(t1));
            ms.erase(ms.find(t2));
            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            while(!ms.empty() && ms.find(t1+t2)!=ms.end())
            {
                len++;
                tmp.pb(t1+t2);
                ms.erase(ms.find(t1+t2));
                swap(t1,t2);
                t2+=t1;
            }
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                ms.insert(tmp[k]);
        }
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    multiset <ll> ms;
    ll a[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ms.insert(a[i]);
    }
    ll x = ms.count(0);
    ll ans = max(2LL,x);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i==j)continue;
            if(a[i]==0 && a[j]==0)continue;
            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            ms.erase(ms.find(t1));
            ms.erase(ms.find(t2));
            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            while(!ms.empty() && ms.find(t1+t2)!=ms.end())
            {
                len++;
                tmp.pb(t1+t2);
                ms.erase(ms.find(t1+t2));
                swap(t1,t2);
                t2+=t1;
            }
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                ms.insert(tmp[k]);
        }
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e3;
const ll mod = 1e7 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;

    map <ll,ll> mp;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans = max(2LL,mp[0]);

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n,i!=j;j++)
        {
            if(a[i]==0 && a[j]==0)continue;

            ll len = 2;
            ll t1 = a[i], t2 = a[j];
            mp[t1]--;
            mp[t2]--;

            vector <ll> tmp;
            tmp.pb(t1);
            tmp.pb(t2);
            //cout<<t1<<"\n"<<t2<<"\n";
            while(mp.find(t1+t2)!=mp.end() && mp[t1+t2]>0)
            {
              //  cout<<t1+t2<<"\n";
                len++;
                tmp.pb(t1+t2);
                mp[t1+t2]--;
                swap(t1,t2);
                t2 += t1;
            }
            //cout<<len<<"\n";
            ans = max(ans,len);
            for(ll k=0;k<tmp.size();k++)
                mp[tmp[k]]++;
            //break;
        }
        //break;
    }
    cout<<ans;

    return 0;
}