#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long w = 1, q = 0;
  char ch = ' ';
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
  return w * q;
}
const int maxn = 9 + 2e5;
const long long mod1 = 998244353;
const long long mod2 = 1000000007;
const long long mod3 = 1000000009;
int _;
long long qpow(long long m, long long n, long long mod) {
  long long temp;
  if (n == 0) return 1;
  temp = qpow(m, n >> 1, mod);
  if (n % 2 == 0)
    return temp * temp % mod;
  else
    return m * temp % mod * temp % mod;
}
int main() {
  int n = read();
  long long a[maxn];
  for (int i = 0; i < n; i++) a[i] = read();
  long long ans = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (i == j || j == k || k == i) continue;
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  if (n == 2) ans = a[0] | a[1];
  if (n == 1) ans = a[0];
  printf("%lld\n", ans);
  return 0;
}
