#include using namespace std; int64_t shift(int64_t x) { return x / 2 + (1ull << 15) * (x % 2); } int main() { int64_t N; cin >> N; vector A(N); for (int64_t& a : A) { cin >> a; } const int64_t M = 16; const int64_t max_bit = (1ull << M); vector can_make(max_bit, false); can_make[0] = true; for (int64_t i = 0; i < N; i++) { vector new_can_make = can_make; for (int64_t k = 0; k < M; k++) { for (int64_t j = 0; j < max_bit; j++) { const int64_t nj = (j | A[i]); new_can_make[nj] = (new_can_make[nj] || can_make[j]); } A[i] = shift(A[i]); } can_make = new_can_make; if (can_make[max_bit - 1]) { cout << max_bit - 1 << endl; return 0; } } for (int64_t i = max_bit - 1; i >= 0; i--) { if (can_make[i]) { cout << i << endl; return 0; } } }