#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int N; cin>>N; vector A(N); rep(i,N){ cin>>A[i]; } vector dp(1024,false); dp[0] = true; bitset<21000000> B; B[0] = true; rep(i,N){ B <<= A[i]; rep(j,1024){ if(dp[j]){ B[j&A[i]] = true; } } vector ndp(1024,false); rep(j,1024){ if(dp[j])ndp[(j + A[i])%1024] = true; if(B[j])ndp[j] = true; } swap(dp,ndp); cout<