#include using namespace std; using ll = long long; using ld = long double; const ll mod = 998244353; const ll INF = (1LL << 60); int shift(int x) { return (x / 2) + (1 << 15) * (x % 2); } int main() { int N; cin >> N; vector A(N); for(int i = 0; i < N; i++) cin >> A[i]; sort(A.rbegin(), A.rend()); int ans = 0; for(int i = 0; i < N; i++) { int rev = ans; for(int cnt = 0; cnt <= 16; cnt++) { rev = max(rev, (ans | A[i])); A[i] = shift(A[i]); } ans = rev; } cout << ans << endl; return 0; }