#include <bits/stdc++.h>
char *fs, *ft, buf[1 << 20];
inline int read() {
  int x = 0, f = 1;
  char ch =
      (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
          ? 0
          : *fs++;
  ;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
             ? 0
             : *fs++;
    ;
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
             ? 0
             : *fs++;
    ;
  }
  return x * f;
}
using namespace std;
long long a[509];
int main() {
  int n;
  long long maxx = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  if (n <= 3) {
    for (int i = 1; i <= n; i++) maxx |= a[i];
  } else {
    long long g = 0;
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++)
        for (int k = j + 1; k <= n; k++) maxx = max(maxx, a[i] | a[j] | a[k]);
  }
  printf("%lld\n", maxx);
  return 0;
}
