#include #include #include using namespace std; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i> N; vector prvs(D + 1, 0), js; unordered_map dp, dpnxt; dp[0] = 1; for (int i = 1; i <= N; ++i) { int a; cin >> a; REP(d, D) { if ((a >> d) & 1) prvs.at(d) = i; } prvs.back() = i; dpnxt.clear(); // unordered_map dpnxt; for (int j : prvs) { if (j <= 0) continue; long long sum = 0; for (auto [jprv, cnt] : dp) { if (jprv <= j) sum += cnt; } dpnxt[j] = sum % md; } swap(dp, dpnxt); // dp = dpnxt; } long long ret = 0; for (auto [k, v] : dp) ret += v; cout << ret % md << endl; }