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

const long long MAXN=50007;


long long a[MAXN+10];

long long n;
bool vis[MAXN+10];

long long curr=0;

void dfs(long long x)
{
    vis[x]=true;
    curr=(curr|a[x]);
    for (long long next=1; next<=n; next++)
    {
        if (x==next || (a[x]&a[next])==0) continue;
        if (vis[next]) continue;
        dfs(next);
    }
    return;
}

int main ()
{
    cin>>n;

    for (long long i=1; i<=n; i++) cin>>a[i];



    long long ans=0;

    for (long long i=1; i<=n; i++)
    {
        curr=0;
        if (!vis[i]) dfs(i);
        long long br=0;
        long long tek=1;
        for (long long j=0; j<20; j++)
        {
            if (curr&tek) br++;
            tek*=2;
        }
        ans=max(ans, br);
    }
    cout<<ans<<endl;
}
