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