// Exported by Exporter.exe // Included from Review.cpp #include using namespace std; #define PB push_back #define F first #define S second #define MP make_pair #define MTP make_tuple #define R Read #define RD Read_Digit #define RP Read_P #define RL Read_Loop #define RLD Read_Loop_Digit #define RLP Read_Loop_P #ifdef ONLINE_JUDGE #define Debug(x) ; #define Debug_Array(n,x) ; #else #define Debug(x) _Debug((#x), (x)) #define Debug_Array(n,x) _Debug_Array((n), (#x), (x)) #endif typedef long long int ll; typedef unsigned long long int ull; constexpr int kN = int(2E4 + 10); constexpr int kC = 1 << 10; // constexpr int kMod = 998244353; // constexpr int kMod = int(1E9 + 7); // constexpr int kInf = 0x3f3f3f3f; // constexpr ll kInf = 0x3f3f3f3f3f3f3f3f; // constexpr double kPi = acos(-1); // constexpr double kEps = 1E-9; // Included from C:\Users\ianli\Desktop\CP\template\Various\Fast_IO\Fast_IO.cpp // --- Get --- static inline char Get_Raw_Char() { static char buf[1 << 16], *p = buf, *end = buf; if (p == end) { if ((end = buf + fread(buf, 1, 1 << 16, stdin)) == buf) return '\0'; p = buf; } return *p++; } // --- Read --- template static inline void Read_P(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); return ; } template static inline void Read(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); if (neg) n = -n; return ; } template static inline void Read_Digit(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); return ; } // --- Read multiple --- template static inline void Read(T &n, Targs&... Fargs) {Read(n); return Read(Fargs...);} template static inline void Read_Digit(T &n, Targs&... Fargs) {Read_Digit(n); return Read_Digit(Fargs...);} template static inline void Read_P(T &n, Targs&... Fargs) {Read_P(n); return Read_P(Fargs...);} // --- Read Loop --- template static inline void Read_Loop_i(int i, T *a) {return Read(a[i]);} template static inline void Read_Loop_i(int i, T *a, Targs*... Fargs) {Read(a[i]); return Read_Loop_i(i, Fargs...);} template static inline void Read_Loop(int n, Targs*... Fargs) {for (int i = 1; i <= n; i++) Read_Loop_i(i, Fargs...);} template static inline void Read_Loop_Digit_i(int i, T *a) {return Read_Digit(a[i]);} template static inline void Read_Loop_Digit_i(int i, T *a, Targs*... Fargs) {Read_Digit(a[i]); return Read_Loop_Digit_i(i, Fargs...);} template static inline void Read_Loop_Digit(int n, Targs*... Fargs) {for (int i = 1; i <= n; i++) Read_Loop_Digit_i(i, Fargs...);} template static inline void Read_Loop_P_i(int i, T *a) {return Read_P(a[i]);} template static inline void Read_Loop_P_i(int i, T *a, Targs*... Fargs) {Read_P(a[i]); return Read_Loop_P_i(i, Fargs...);} template static inline void Read_Loop_P(int n, Targs*... Fargs) {for (int i = 1; i <= n; i++) Read_Loop_P_i(i, Fargs...);} // --- Float --- template static inline void Read(T &n) { char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); int cnt = 0; if (c == '.') { while (isdigit(c = Get_Raw_Char())) { n = n * 10 + int(c - '0'); cnt++; } } while (cnt < mul) { n = n * 10; cnt++; } if (neg) n = -n; return ; } template static inline void Read_P(T &n) { char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); int cnt = 0; if (c == '.') { while (isdigit(c = Get_Raw_Char())) { n = n * 10 + int(c - '0'); cnt++; } } while (cnt < mul) { n = n * 10; cnt++; } return ; } template static inline void Read(T &n, Targs&... Fargs) {Read(n); return Read(Fargs...);} template static inline void Read_P(T &n, Targs&... Fargs) {Read_P(n); return Read_P(Fargs...);} inline void IOS() {ios::sync_with_stdio(false); cin.tie(0);} // --- freopen --- inline void Freopen(const char *in, const char *out) { freopen(in, "r", stdin); freopen(out, "w", stdout);} // --- Output --- template void Print(T x) { if (x < 0) { printf("-"); x = -x; } if (x == 0) printf("0"); else { static int val[100]; int idx = -1; while (x) { val[++idx] = x % 10; x /= 10; } while (idx >= 0) printf("%d", val[idx--]); } } // End of C:\Users\ianli\Desktop\CP\template\Various\Fast_IO\Fast_IO.cpp // Included from C:\Users\ianli\Desktop\CP\template\Various\Useful_Functions\Useful_Functions.cpp template inline void sort(vector &v) {return sort(v.begin(), v.end());} template inline void sort(int n, T *a) {return sort(a + 1, a + n + 1);} template inline void sort_r(vector &v) {return sort(v.begin(), v.end(), greater());} template inline void sort_r(int n, T *a) {return sort(a + 1, a + n + 1, greater());} template inline void Merge(vector &a, vector &b, vector &c) { if (c.size() < a.size() + b.size()) c.resize(a.size() + b.size()); merge(a.begin(), a.end(), b.begin(), b.end(), c.begin()); return ; } template inline void Discrete(vector &v) {sort(v); v.resize(unique(v.begin(), v.end()) - v.begin());} template using PQ = priority_queue; template using PQ_R = priority_queue, greater>; template inline T ABS(T n) {return n >= 0 ? n : -n;} template inline T gcd(T a, T b) {return b ? gcd(b, a % b) : a;} template inline T lcm(T a, T b) {return a * b / gcd(a, b);} template inline void chmin(T &a, T b) { a = min(a, b); return ; } template inline void chmax(T &a, T b) { a = max(a, b); return ; } template inline int Digit_Sum(T a) { int ans = 0; while (a) { ans += a % 10; a /= 10; } return ans; } // End of C:\Users\ianli\Desktop\CP\template\Various\Useful_Functions\Useful_Functions.cpp // Included from C:\Users\ianli\Desktop\CP\template\Various\Debug\Debug.cpp void _print(int x) {printf("%d", x);} void _print(long long int x) {printf("%lld", x);} void _print(double x) {printf("%lf", x);} template void _print(pair x) {printf("("); _print(x.first); printf(", "); _print(x.second); printf(")");} template void _Debug(const char *s, T x) {printf("%s = ", s); _print(x); printf("\n");} template void _Debug(const char *s, vector v) { printf("%s :", s); if (v.empty()) printf(" empty"); else for (T i : v) printf(" "), _print(i); printf("\n"); } template void _Debug(const char *s, priority_queue pq) { printf("%s :", s); if (pq.empty()) printf(" empty"); else { while (!pq.empty()) { printf(" "); _print(pq.top()); pq.pop(); } } printf("\n"); } template void _Debug(const char *s, queue q) { printf("%s :", s); if (q.empty()) printf(" empty"); else { while (!q.empty()) { printf(" "); _print(q.front()); q.pop(); } } printf("\n"); } template void _Debug(const char *s, stack st) { printf("%s :", s); if (st.empty()) printf(" empty"); else { while (!st.empty()) { printf(" "); _print(st.top()); st.pop(); } } printf("\n"); } template void _Debug(const char *s, deque dq) { printf("%s :", s); if (dq.empty()) printf(" empty"); else { while (!dq.empty()) { printf(" "); _print(dq.front()); dq.pop_front(); } } printf("\n"); } template void _Debugln(const char *s, vector v) { printf("%s :", s); if (v.empty()) printf(" empty\n"); else { for (T i : v) printf("\n"), _print(i); printf("\n"); } } template void _Debugln(const char *s, priority_queue pq) { printf("%s :", s); if (pq.empty()) printf(" empty"); else { while (!pq.empty()) { printf("\n"); _print(pq.top()); pq.pop(); } } printf("\n"); } template void _Debugln(const char *s, queue q) { printf("%s :", s); if (q.empty()) printf(" empty"); else { while (!q.empty()) { printf("\n"); _print(q.front()); q.pop(); } } printf("\n"); } template void _Debugln(const char *s, stack st) { printf("%s :", s); if (st.empty()) printf(" empty"); else { while (!st.empty()) { printf("\n"); _print(st.top()); st.pop(); } } printf("\n"); } template void _Debugln(const char *s, deque dq) { printf("%s :", s); if (dq.empty()) printf(" empty"); else { while (!dq.empty()) { printf("\n"); _print(dq.front()); dq.pop_front(); } } printf("\n"); } template void _Debug_Array(int n, const char *s, const T *x) {printf("%s :", s); for (int i = 1; i <= n; i++) printf(" "), _print(x[i]); printf("\n");} template void _Debugln_Array(int n, const char *s, const T *x) {printf("%s :\n", s); for (int i = 1; i <= n; i++) _print(x[i]), printf("\n");} // End of C:\Users\ianli\Desktop\CP\template\Various\Debug\Debug.cpp int a[kN]; bitset Mul, And, lst; int main() { int n; RP(n); RLP(n, a); lst[1] = true; bool have_zero = false; bool have_one = true; int ans = 1; for (int i = 1; i <= n; i++) { if (a[i] == 0) { while (i++ <= n) printf("1\n"); break; } And.reset(); Mul.reset(); for (int j = 0; j < kC; j++) if (lst[j]) { Mul[j * a[i] % kC] = true; And[j & a[i]] = true; } for (int j = 0; j <= a[i]; j++) if (And[j]) ans++; if (have_zero && And[0]) ans--; if (have_one && And[a[i]]) ans--; if (And[0]) have_zero = true; have_one = And[1]; lst = Mul | And; printf("%d\n", ans); } } // End of Review.cpp