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