#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  long long s = 0, f = 0, ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return f ? -s : s;
}
const long long N = 1e6 + 5;
const long long mod = 1e9 + 7;
long long n, m, k;
long long a[N], b[N], f[N];
long long qp(long long a, long long b) {
  long long sum = 1;
  while (b) {
    if (b & 1) sum = sum * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return sum;
}
bool flag[N];
long long p[N], tot;
long long find(long long x) { return x == f[x] ? x : f[x] = find(f[x]); }
long long c[N];
vector<long long> g[N];
void work() {
  n = in();
  for (long long i = 1; i <= (n); ++i) {
    a[i] = in();
  }
  long long ans = 0;
  for (long long i = 1; i <= (n); ++i) {
    for (long long j = i; j <= (n); ++j) {
      for (long long k = j; k <= (n); ++k) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  cout << ans << '\n';
}
signed main() {
  work();
  return 0;
}
