#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long arr[n];
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  set<long long> possible;
  for (long long i = 0; i < n; i++) {
    ans = max(ans, arr[i]);
    for (long long j = i + 1; j < n; j++) {
      long long curr2 = arr[i] | arr[j];
      ans = max(ans, curr2);
      for (long long k = j + 1; k < n; k++) {
        long long curr = arr[i] | arr[j] | arr[k];
        ans = max(ans, curr);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
