#include <bits/stdc++.h>
using namespace std;
void setup() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
}
void solve() {
  long long n;
  cin >> n;
  long long o = 2;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long res = 0;
  for (long long i = 0; i < n; ++i) {
    for (long long j = i; j < n; ++j) {
      for (long long k = j; k < n; ++k) res = max(res, a[i] | a[j] | a[k]);
    }
  }
  cout << res;
}
signed main() {
  setup();
  solve();
}
