#include<bits/stdc++.h>
using namespace std;
#define loop(i,l,n) for(long i=l;i<n;i++)
#define push_back emplace_back
const int MOD = 1000000007;
template T gcd(T a, T b){return(b?__gcd(a,b):a);}
template T lcm(T a, T b){return(a*(b/gcd(a,b)));}
void run()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("/home/punit/Documents/Cpp Programs/input.txt","r",stdin);
freopen("/home/punit/Documents/Cpp Programs/output.txt","w",stdout);
#endif
}
int main()
{
run();
int n;
cin>>n;
long arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
long sum = 0;
long bit[32]={0};
int res = 0,count=0;
for(int i=31;i>=0;iā)
** {**
** count = 0;**
** for(int j=0;j<n;j++)**
** {**
** int pattern = res|(1<<i);**
** if((arr[j]&pattern)==pattern)**
** {**
** count++;**
** }**
** // cout<<count<<" ";**
** }**
** if(count>=2)**
** {**
** res|=(1<<i);**
** }**
** }**
cout<<res;
}