#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < i; j++) {
      ans = max(ans, a[i] | a[j]);
      for (long long k = 0; k < j; k++) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  ans = max(ans, a[0]);
  cout << ans << '\n';
  return 0;
}
