#include #include // cout, endl, cin #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include #include using namespace std; using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) typedef long long ll; typedef unsigned long long ull; const ll inf=1e18+1; using graph = vector > ; using P= pair; using vi=vector; using vvi=vector; using vll=vector; using vvll=vector; using vp=vector

; using vpp=vector; //string T="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //string S="abcdefghijklmnopqrstuvwxyz"; //g++ main.cpp -std=c++14 -I . //cout <> n; vi a(n);rep(i,n)cin >> a[i]; ll Bit=1ll<<16; if(n>=16){ ll ans=Bit-1; cout << ans << endl; return 0; } auto f=[&](int i){ return i/2+(1<<15)*(i&1); }; vvi dp(n+1,vi(Bit)); dp[0][0]=1; rep(i,n)rep(j,Bit){ rep(k,17){ a[i]=f(a[i]); int nj=j|a[i]; dp[i+1][nj]|=dp[i][j]; } } int ans=0; rep(i,Bit)if(dp[n][i])ans=i; cout << ans << endl; }