#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; if(N >= 16) { cout << (1 << 16) - 1 << endl; } else { vector A(N); rep(i,N) cin >> A[i]; int LIM = (1 << 16); vector> dp(N + 1, vector(LIM, 0)); dp[0][0] = 1; rep(i,N) { rep(x,LIM) { rep(_,15) { dp[i + 1][x | A[i]] |= dp[i][x]; A[i] = (A[i] / 2) + (1 << 15) * (A[i] % 2); } } } int ans = 0; rep(x,LIM) if(dp[N][x]) ans = max(ans, x); cout << ans << endl; } }