#include <bits/stdc++.h>
using namespace std;
const long long N = 555;
long long n, a[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cout.precision(40);
  cin >> 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 = 0; j < n; ++j) {
      for (long long k = 0; k < n; ++k) {
        if ((a[i] | a[j] | a[k]) > res) res = a[i] | a[j] | a[k];
      }
    }
  }
  cout << res;
}
