#include <bits/stdc++.h>
using namespace std;
const int MAXN = 510;
int n;
long long a[MAXN], ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  if (n == 1) {
    printf("%lld\n", a[1]);
  } else if (n == 2) {
    printf("%lld\n", a[1] | a[2]);
  } else {
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        for (int k = j + 1; k <= n; k++) {
          ans = max(ans, a[i] | a[j] | a[k]);
        }
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
