#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e9;
long long int n, a[505];
long long int solve() {
  cin >> n;
  if (n == 1) return n;
  if (n == 2) {
    cin >> a[1] >> a[2];
    return a[1] | a[2];
  }
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++)
    for (long long int j = 1; j <= n; j++)
      for (long long int k = 1; k <= n; k++) ans = max(ans, a[i] | a[j] | a[k]);
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << solve();
  return 0;
}
