#include <bits/stdc++.h>
using namespace std;
void desperate_optimization(int precision) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
const int N = 21;
const int MAXN = (1 << N);
int occ[MAXN + 5];
int arr[MAXN + 5];
void add(int u, int k) {
  if (occ[u] >= 2) return;
  occ[u]++;
  for (int i = k; i >= 0; i--) {
    if (u & (1 << i)) add(u ^ (1 << i), i);
  }
}
void hora(int tc) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int res = 0;
  for (int i = n - 1; i >= 0; i--) {
    int tot = 0;
    for (int j = N; j >= 0; j--) {
      if (!(arr[i] & (1 << j))) {
        if (occ[tot | (1 << j)] >= 2) {
          tot |= (1 << j);
        }
      }
    }
    if (i <= n - 3) res = max(res, tot | arr[i]);
    add(arr[i], N);
  }
  cout << res << '\n';
}
int main() {
  desperate_optimization(10);
  int ntc = 1;
  for (int tc = 1; tc <= ntc; tc++) hora(tc);
  return 0;
}
