#include <bits/stdc++.h>
using namespace std;
long long int binpow(long long int x, long long int y) {
  long long int res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, f = 0, j, ans = 0, k, x, r, l, t, n;
  cin >> n;
  ans = 0;
  long long int a[n];
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      for (k = 0; k < n; ++k) ans = std::max(ans, a[i] | a[j] | a[k]);
    }
  }
  cout << ans;
  return 0;
}
