#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n;
  cin >> n;
  vector<unsigned long long> num(n);
  for (int i = 0; i < n; i++) {
    unsigned long long a;
    cin >> a;
    num[i] = a;
  }
  if (n <= 3) {
    unsigned long long ans = 0;
    for (int i = 0; i < n; i++) {
      ans |= num[i];
    }
    cout << ans << endl;
    return 0;
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        unsigned long long a = num[i] | num[j] | num[k];
        if (a > ans) ans = a;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
