#include <bits/stdc++.h>
char *fs, *ft, buf[1 << 20];
inline long long read() {
  long long x = 0, f = 1;
  char ch =
      (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
          ? 0
          : *fs++;
  ;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
             ? 0
             : *fs++;
    ;
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
             ? 0
             : *fs++;
    ;
  }
  return x * f;
}
using namespace std;
const long long N = 1e6 + 5;
const long long inf = 0x3f3f3f3f;
const long long mod1 = 1e9 + 7;
const long long mod2 = 993471257;
const double eps = 1e-7;
const double PI = acos(-1);
long long a[1000], b[100], c[1000];
signed main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[1] << '\n';
  } else if (n == 2) {
    cout << (a[1] | a[2]) << '\n';
  } else {
    long long res = 0;
    for (long long i = 1; i <= n; i++) {
      for (long long j = i + 1; j <= n; j++) {
        for (long long k = j + 1; k <= n; k++) {
          res = max(res, a[i] | a[j] | a[k]);
        }
      }
    }
    cout << res << '\n';
  }
}
