#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef vector <ll> vll;
typedef set <ll> sll;
typedef vector <vector<ll>> vvll;
typedef set<pair<ll,ll>> spll;
typedef vector <bool> vbl;
ll LMA=LLONG_MAX;
ll LMI=LLONG_MIN;

template<typename T>
using ordered_set = tree<
    T,
    null_type,
    less<T>,
    rb_tree_tag,
    tree_order_statistics_node_update>;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll t=1;
    // cin>>t;
    
    while (t--)
    {
        ll n;
        cin>>n;
        vll v(n+1);
        for (ll i=1;i<=n;i++)
        {
            cin>>v[i];
        }
        if (n==1)
        {
            cout<<v[1]<<"\n";
            return 0;
        }
        if (n>=15)
        {
            cout<<"32767"<<"\n";
        } else 
        {
            ll answer=0;
            for (ll i=1;i<=n;i++)
            {
                answer |= v[i];
            }
            for (ll i=1;i<=(n-1);i++)
            {
                for (ll j=i+1;j<=n;j++)
                {
                    vll temp=v;
                    temp[i] ^= (1<<15)-1;
                    temp[j] ^= (1<<15)-1;
                    ll res=0;
                    for (ll k=1;k<=n;k++)
                    {
                        res |= temp[k];
                    }
                    answer=max(answer,res);
                }
            }
            cout<<answer<<"\n";
        }
    }
    
    return 0;
}