// ඞඞඞඞඞඞ you sus
#include <bits/stdc++.h>

#define __builtin_popcount __builtin_popcountll
#define BIT(x, i) (((x)>> (i))& 1)
#define MASK(x) (1LL<< (x))
#define sqr(x) ((x)* (x))
#define MOD 1000000007
#define template(i) for(long long i= 1; i<= n; i++)

using namespace std;

typedef long long ll;

template<class X,class Y>
    void minimize(X &x,const Y y) {
        if (x>y) x= y;
    }
template<class X,class Y>
    void maximize(X &x,const Y y) {
        if (x<y) x= y;
    }
template<class T>
    T Abs(const T x) {
        return (x<0?-x:x);
    }

template <class T>
    void Mod(T &t) {
        if(t>= MOD) t-= MOD;
    }

template <class X, class Y>
    ll Gcd(const X a, const Y b){
        if(b== 0)   return a;
        else return Gcd(b, a% b);
    }

template <class X, class Y>
    ll Lcm(const X a, const Y b){
        return ((a*b)/gcd(a, b));
    }

template <class X, class Y>
    void Add(X &x, const Y y){
        if((x+= y)>= MOD) x-= MOD;
    }

const int maxm= (int)1e6+ 3, maxn= (int)1e5 +3, maxpst= (int)17e5, maxb= (int)1e3+ 3;

const ll INF= (ll)1e18+ 3;

vector<ll> adj[maxb];

vector<ll> topo;
ll n, a[maxb], f[maxb], ans= 0, vis[maxb];

void Dfs(ll u){
    vis[u]= 1;
    for(long long i= 0; i< adj[u].size(); i++){
        ll v= adj[u][i];
        if(!vis[v])
            Dfs(v);
    }
    topo.push_back(u);
}

void printans(){
    cout<< ans;
}

void solve(){
    for(int i= 1; i<= n; i++){
        for(int j= 1; j<= n; j++){
            for(int k= 1; k<= n; k++){
                if((i== j)|| (i== k)|| (j== k)) continue;
                if(a[i]+ a[j]== a[k]){
                    adj[i].push_back(k);
                    adj[j].push_back(k);
                }
            }
        }
    }
    for(long long i= 1; i<= n; i++){
        if(vis[i]== 0){
            Dfs(i);
        }
    }
    reverse(topo.begin(), topo.end());
    for(long long i= 1; i<= n; i++){
        f[i]= 1;
    }
    for(long long i= 0; i< n; i++){
        ll u= topo[i];
        for(long long j= 0; j< adj[u].size(); j++){
            ll v= adj[u][j];
            maximize(f[v], f[u]+ 1);
        }
        maximize(ans, f[u]);
    }
}

void input(){
    cin>> n;
    for(long long i= 1; i<= n; i++){
        cin>> a[i];
    }
    solve();
    printans();
}

int main()

{   ios_base::sync_with_stdio(0);cin.tie(0);
    #define task ""
    if(fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    if(fopen("task.inp", "r")){
        freopen("task.inp", "r", stdin);
        freopen("task.out", "w", stdout);
    }
    input();
    return 0;
}
