#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n;
  long long mx = 0;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> v[i];
  }
  if (n < 3) {
    cout << accumulate(v.begin(), v.end(), 0, bit_or<long long>()) << "\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        mx = max((v[i] | v[j] | v[k]), mx);
      }
    }
  }
  cout << mx << "\n";
  return 0;
}
