#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e18;
const long long minN = -1e18;
const long long MOD = 1e9 + 7;
const long long MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const long double PI = acos(-1);
const long long limit = 2e5 + 5;
const long long limit1 = 1e6 + 5;
const long long limit2 = 1e3 + 5;
long long n;
long long a[limit];
long long ans = 0;
void solveProblem() {
  ans = a[1] | a[2] | a[3];
  for (int i = (1); i <= (n - 2); ++i) {
    for (int j = (i + 1); j <= (n - 1); ++j) {
      for (int k = (j + 1); k <= (n); ++k) {
        ans = max(ans, a[i] | a[j] | a[k]);
      }
    }
  }
  cout << ans << '\n';
}
void fastInput() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void readInput() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) cin >> a[i];
}
int main() {
  fastInput();
  readInput();
  solveProblem();
}
