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