#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++) { bitset B; int x = A[i]; vector seen; while (!B.test(x)) { B.set(x, true); seen.push_back(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; }