#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 505;
int n;
long long ans, a[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    ans = max(ans, a[i]);
    for (int j = i + 1; j <= n; j++) {
      ans = max(ans, (a[i] | a[j]));
      for (int k = j + 1; k <= n; k++) {
        ans = max(ans, (a[i] | a[j] | a[k]));
      }
    }
  }
  cout << ans;
  return 0;
}
