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