#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll md = 1000000007;
ll exp(ll a, ll b) {
  ll r = 1ll;
  while (b > 0) {
    if (b & 1) {
      r = r * (a % md);
      r = (r + md) % md;
    }
    b >>= 1;
    a = (a % md) * (a % md);
    a = (a + md) % md;
  }
  return (r + md) % md;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll Min(ll a, ll b) {
  if (a < b) return a;
  return b;
}
ll Max(ll a, ll b) {
  if (a > b) return a;
  return b;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, ans = 0;
  cin >> n;
  vector<ll> v(n);
  for (ll i = 0; i <= n - 1; ++i) cin >> v[i];
  for (ll i = 0; i <= n - 1; ++i) ans = Max(ans, v[i]);
  for (ll i = 0; i <= n - 2; ++i)
    for (ll j = i + 1; j <= n - 1; ++j) {
      long long val = v[i] | v[j];
      ans = Max(ans, val);
    }
  for (ll i = 0; i <= n - 3; ++i)
    for (ll j = i + 1; j <= n - 2; ++j)
      for (ll k = j + 1; k <= n - 1; ++k) {
        long long val = v[i] | v[j] | v[k];
        ans = Max(ans, val);
      }
  cout << ans;
  cout << '\n';
  return 0;
}
