#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n, m, k;
long long a[N];
int main() {
  int T = 1, x, y;
  cin >> n;
  long long mi = 0, r = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  long long mx = 0;
  if (n == 1) {
    for (int i = 1; i <= n; i++) {
      mx = max(mx, a[i]);
    }
  }
  if (n == 2) {
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        mx = max(mx, a[i] | a[j]);
      }
    }
  }
  if (n >= 3) {
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        for (int k = j + 1; k <= n; k++) {
          mx = max(mx, a[i] | a[j] | a[k]);
        }
      }
    }
  }
  printf("%lld\n", mx);
  return 0;
}
