#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[0];
    return;
  }
  if (n == 2) {
    cout << (long long)(a[0] | a[1]);
    return;
  }
  long long mx = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++) mx = max(mx, a[i] | a[j] | a[k]);
  cout << mx;
}
signed main() {
  int t = 1;
  while (t--) solve();
}
