#include <bits/stdc++.h>
#pragma GCC target("sse4.2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long MAXN = 500 + 7, MOD = 1000 * 1000 * 1000 + 7;
long long a[MAXN];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  long long mx = 0;
  for (long long i = 0; i < n; i++) cin >> a[i], mx = max(mx, a[i]);
  if (n == 2) mx = max(mx, (a[0] | a[1]));
  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++)
        mx = max(mx, ((a[i] | a[j]) | a[k]));
    }
  }
  cout << mx << endl;
  return 0;
}
