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