#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  if (N >= 16){
    cout << (1 << 16) - 1 << endl;
  } else {
    vector<vector<bool>> dp(N + 1, vector<bool>(1 << 16, false));
    dp[0][0] = true;
    for (int i = 0; i < N; i++){
      vector<int> B(16);
      B[0] = A[i];
      for (int j = 0; j < 15; j++){
        B[j + 1] = B[j] / 2 + ((B[j] % 2) << 15);
      }
      for (int j = 0; j < (1 << 16); j++){
        if (dp[i][j]){
          for (int k = 0; k < 16; k++){
            dp[i + 1][j | B[k]] = true;
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < (1 << 16); i++){
      if (dp[N][i]){
        ans = max(ans, i);
      }
    }
    cout << ans << endl;
  }
}