#include using namespace std; int main() { iostream::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; vector A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } if (n > 15) { cout << (1 << 16) - 1 << '\n'; return 0; } const int N = 1 << 16; bitset dp; dp.set(0, true); for (int i = 0; i < n; i++) { set seen; int x = A[i]; while (!seen.count(x)) { seen.insert(x); x = x / 2 + ((x % 2) << 15); } bitset ndp; for (int mask = 0; mask < (1 << 16); mask++) { if (dp.test(mask)) { ndp.set(mask, true); for (int a : seen) { ndp.set(mask | a, true); } } } swap(dp, ndp); } int ans = 0; for (int mask = 0; mask < (1 << 16); mask++) { if (dp.test(mask)) { ans = max(ans, mask); } } cout << ans << '\n'; return 0; }