#include #include #include #include using namespace std; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i> N; vector prvs(D, -1); unordered_map dp; dp[-1] = 1; REP(i, N) { int a; cin >> a; REP(d, D) { if ((a >> d) & 1) prvs.at(d) = i; } auto js = prvs; sort(js.begin(), js.end()); js.erase(unique(js.begin(), js.end()), js.end()); if (js.back() != i) js.push_back(i); reverse(js.begin(), js.end()); if (js.back() == -1) js.pop_back(); unordered_map dpnxt; for (int j : js) { 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; }