#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  if (n <= 3) {
    long long ans = arr[0];
    for (long long i = 1; i < n; ++i) ans |= arr[i];
    cout << ans << '\n';
    return;
  }
  long long maxm = INT_MIN;
  for (long long i = 0; i < n - 2; ++i) {
    for (long long j = i + 1; j < n - 1; ++j) {
      for (long long k = j + 1; k < n; ++k) {
        maxm = max(maxm, (arr[i] | arr[j] | arr[k]));
      }
    }
  }
  cout << maxm << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(static_cast<unsigned>(time(0)));
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
