#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long answer = 0;
    if (n <= 2) {
      for (long long i = 0; i < n; i++) answer |= a[i];
    } else {
      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++) {
            answer = max(answer, (a[i] | a[j] | a[k]));
          }
        }
      }
    }
    cout << answer << "\n";
  }
  return 0;
}
