#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& cout, vector<T> V) {
  cout << "[ ";
  for (auto v : V) cout << v << ' ';
  return cout << ']';
}
template <class L, class R>
ostream& operator<<(ostream& cout, pair<L, R> P) {
  return cout << '(' << P.first << ',' << P.second << ')';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < (n); i++) cin >> a[i];
  a.push_back(0);
  a.push_back(0);
  n += 2;
  long long int ans = 0;
  for (long long int i = 0; i < (n); i++) {
    for (long long int j = i + 1; j < n; j++) {
      for (long long int k = j + 1; k < n; k++) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  cout << ans << '\n';
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  ;
}
