#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void solve() {
  int n;
  cin >> n;
  long long ans = 0;
  vector<long long> a(n);
  for (auto &i : a) cin >> i;
  for (int x = 0; x < n; x++) {
    for (int y = x; y < n; y++) {
      for (int z = y; z < n; z++) {
        ans = max(ans, (a[x] | a[y] | a[z]));
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
