#include <bits/stdc++.h>
using namespace std;
mt19937 mrand(43);
const double PI = acos((double)-1);
const double eps = 1e-5;
const long long inf0 = 1023 * 1024 * 1024;
const long long inf = inf0 * inf0;
const long long mod = 1e9 + 7;
void solve();
void scan();
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed;
  cout.precision(15);
  solve();
  return 0;
}
void solve() {
  int n;
  cin >> n;
  long long ans = 0;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      for (int k = j; k < n; k++) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  cout << ans << '\n';
  return;
}
