#include <bits/stdc++.h>
using namespace std;
long long int powm(long long int x, long long int y,
                   long long int m = 1000000007) {
  x = x % m;
  long long int res = 1;
  while (y) {
    if (y & 1) res = res * x;
    res %= m;
    y = y >> 1;
    x = x * x;
    x %= m;
  }
  return res;
}
long long int modi(long long int a, long long int m = 1000000007) {
  return powm(a, m - 2, m);
}
void pre() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  pre();
  {
    long long int n, as = 0, mb = 0;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    if (n == 1) as = a[0];
    if (n == 2) as = (a[1] | a[0]);
    for (long long int i = 0; i < n - 2; i++) {
      for (long long int j = i + 1; j < n - 1; j++) {
        for (long long int k = j + 1; k < n; k++)
          as = max(as, a[i] | a[j] | a[k]);
      }
    }
    cout << as;
  }
  return 0;
}
