#include using namespace std; using ll = long long; using P = pair; #define rep(i, a, b) for(ll i = a; i < b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) constexpr ll inf = 4e18; struct SetupIO { SetupIO() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(30); } } setup_io; int main(void) { int n; cin >> n; if(n >= 16) { cout << (1 << 16) - 1 << '\n'; return 0; } vector a(n); rep(i, 0, n) { cin >> a[i]; } vector> dp(n + 1, vector(1 << 16, false)); dp[0][0] = true; rep(i, 0, n) { rep(j, 0, 1 << 16) { rep(k, 0, 16) { dp[i + 1][j] = dp[i + 1][j] | dp[i][j]; dp[i + 1][j | a[i]] = dp[i + 1][j | a[i]] | dp[i][j]; a[i] = (a[i] >> 1) + (1 << 15) * (a[i] & 1); } } } int ans = 0; rep(i, 0, 1 << 16) { if(dp[n][i]) ans = i; } cout << ans << '\n'; }