#include using namespace std; int main(){ auto f = [&](int x){return x / 2 + (1 << 15) * (x & 1);}; int n; cin >> n; vector a(n); for(auto &&v:a)cin >> v; if(n >= 16){ cout << (1 << 16) - 1 << '\n'; return 0; } vector> dp(n + 1, vector(1 << 16)); dp[0][0] = true; for(int i = 0; i < n; i++){ vector b; for(int j = 0; j < 16; j++){ b.push_back(a[i]); a[i] = f(a[i]); } for(int j = 0; j < (1 << 16); j++){ if(dp[i][j]){ for(auto &&S:b)dp[i + 1][j | S] = true; } } } for(int j = (1 << 16) - 1; j >= 0; j--){ if(dp[n][j]){ cout << j << '\n'; return 0; } } }