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