#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[0];
    return;
  } else if (n == 2) {
    cout << (a[0] | a[1]);
    return;
  }
  sort(a.rbegin(), a.rend());
  long long maxx = 0;
  for (int shift = 32; shift >= 0; shift--) {
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        for (int k = j + 1; k < n; k++) {
          long long x = (a[i] | a[j]) | a[k];
          maxx = max(maxx, x);
        }
      }
    }
  }
  cout << maxx << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
