#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const unsigned long long inf = 1e18;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<unsigned long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  unsigned long long ans = 0;
  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";
}
