#include #include #include using namespace std; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i> N; vector prvs(D + 1, -1), js; unordered_map dp; dp[-1] = 1; REP(i, N) { int a; cin >> a; REP(d, D) { if ((a >> d) & 1) prvs.at(d) = i; } prvs.back() = i; 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; } dp = dpnxt; } long long ret = 0; for (auto [k, v] : dp) ret += v; cout << ret % md << endl; }