#include <bits/stdc++.h>
const int bitlimit = 63;
long long int max(long long int a, long long int b) { return a > b ? a : b; }
int main(int argc, char **argv) {
  int n;
  scanf("%d", &n);
  std::vector<long long int> a(n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  long long int answer = a[0];
  if (n >= 2) answer = a[0] | a[1];
  for (int i1 = 0; i1 < n; i1++) {
    for (int i2 = i1 + 1; i2 < n; i2++) {
      for (int i3 = i2 + 1; i3 < n; i3++) {
        answer = max(answer, a[i1] | a[i2] | a[i3]);
      }
    }
  }
  printf("%lld\n", answer);
  return 0;
}
