#include <bits/stdc++.h>
long long quickpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 1000000007;
    b >>= 1, a = a * a % 1000000007;
  }
  return ans;
}
using namespace std;
const long long N = 1e6 + 7;
const long long maxn = 5e2 + 9;
long long a[maxn];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[1] << endl;
    return;
  }
  if (n == 2) {
    cout << (a[1] | a[2]) << endl;
    return;
  }
  long long ans = 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++) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
