#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  {
    long long n;
    cin >> n;
    long long arr[n];
    for (long long i = 0; i < n; i++) cin >> arr[i];
    long long ans = 0;
    if (n < 4) {
      for (long long i = 0; i < n; i++) ans = ans | arr[i];
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = i + 1; j < n; j++) {
        for (long long k = j + 1; k < n; k++) {
          long long temp = arr[i] | arr[j];
          temp |= arr[k];
          ans = max(ans, temp);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
