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