#include <bits/stdc++.h>
using namespace std;
static const int INF = 1e9;
static const int MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  long long a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      for (int k = j; k < N; k++) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  cout << ans << endl;
}
