#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, unsigned long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x;
    }
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long int powermod(long long int x, unsigned long long int y,
                       long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v, bits(61), ind[60];
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    long long int t;
    cin >> t;
    v.push_back(t);
    for (long long int j = (long long int)(0); j < (long long int)(60); j++) {
      if ((1ll << j) & t) bits[j]++, ind[j].push_back(i);
    }
  }
  long long int ans = 0;
  if (n < 3) {
    for (long long int j = (long long int)(0); j < (long long int)(60); j++)
      if (bits[j]) ans += (1ll << j);
    cout << ans << "\n";
    return 0;
  }
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    for (long long int j = (long long int)(i + 1); j < (long long int)(n);
         j++) {
      for (long long int k = (long long int)(j + 1); k < (long long int)(n);
           k++) {
        ans = max(ans, (v[i] | v[j] | v[k]));
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
