#include <bits/stdc++.h>
using namespace std;
const long long MOD = ((long long)1e9 + 7);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, ans = 0;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < n; ++j)
      for (long long k = 0; k < n; ++k) ans = max(ans, a[i] | a[j] | a[k]);
  cout << ans << "\n";
}
