#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
vector<int> getFactorization(int x) {
  int MAXN = 100001;
  int spf[MAXN];
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++) spf[i] = i;
  for (int i = 4; i < MAXN; i += 2) spf[i] = 2;
  for (int i = 3; i * i < MAXN; i++) {
    if (spf[i] == i)
      for (int j = i * i; j < MAXN; j += i)
        if (spf[j] == j) spf[j] = i;
  }
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
long long exp(long long n, long long m) {
  long long a = 1;
  while (m) {
    if (m & 1) a = (a * n % 1000000007) % 1000000007;
    m /= 2;
    n = (n * n) % 1000000007;
  }
  return a;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, t = 1;
  while (t--) {
    cin >> n;
    long long a[n], ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < n; k++) ans = max(ans, a[i] | a[j] | a[k]);
    cout << ans << "\n";
  }
  return 0;
}
