#include using namespace std; #include using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n+1); i++) #define repn(i,a,b) for (int i = (int)(a) ; i < (int)(b+1); i++) #define repv(i, n) for (int i = (int)(n-1); i >= 0; i--) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define sz(x) ((int)(x).size()) #define cauto const auto& #define bit(n) (1LL<<(n)) #define uni(v) v.erase( unique(v.begin(), v.end()), v.end() ); using ll = long long; using P = pair; using PP = pair; using Graph = vector>; using mint = modint998244353; #ifdef LOCAL #include #define debug(...) debug::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif int shift(int x){ return (x%2==0) ? x/2 : x/2+pow(2,15); } int main(){ int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; if(n > 16){ cout << 65535 << endl; } else{ vector> dp(2,vector(bit(16),false)); int now = a[0]; vector check; rep(i,16){ dp[0][now] = true; check.push_back(now); now = shift(now); } rep(i,n-1){ vector next; rep(j,sz(check)){ if(dp[i%2][check[j]]){ now = a[(i+1)]; rep(k,16){ dp[(i+1)%2][now|check[j]] = true; next.push_back(now|check[j]); now = shift(now); } } } check = next; } int ans = 0; rep(i,bit(16)){ if(n%2 == 0){ if(dp[1][i]) ans = max(ans,i); } else { if(dp[0][i]) ans = max(ans,i); } } cout << ans << endl; } return 0; }