#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector RUI = A; RUI.push_back(0); for (int i = N - 1; i >= 0; --i) { RUI[i] += RUI[i + 1]; } bool dp[N + 1][2][1024]; memset(dp, false, sizeof(dp)); dp[0][1][0] = true; int ans = 1; vector memo(N * 1024, false); memo[RUI[0]] = true; for (int i = 0; i < N; ++i) { int a = A[i]; for (int k = 0; k < 1024; ++k) { if (!dp[i][0][k] && !dp[i][1][k]) continue; dp[i + 1][0][(k + a) % 1024] = true; dp[i + 1][1][k & a] = true; } for (int k = 0; k < 1024; ++k) { if (not dp[i + 1][1][k]) continue; int v = k + RUI[i + 1]; if (memo[v]) continue; memo[v] = true; ++ans; } cout << ans << endl; } return 0; }