/* -*- coding: utf-8 -*- * * 1741.cc: No.1741 Arrays and XOR Procedure - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MOD = 998244353; /* typedef */ template struct MI { int v; MI(): v() {} MI(int _v): v(_v % MOD) {} MI(long long _v): v(_v % MOD) {} MI operator+(const MI m) const { return MI(v + m.v); } MI operator-(const MI m) const { return MI(v + MOD - m.v); } MI operator*(const MI m) const { return MI((long long)v * m.v); } MI &operator+=(const MI m) { return (*this = *this + m); } MI &operator-=(const MI m) { return (*this = *this - m); } MI &operator*=(const MI m) { return (*this = *this * m); } MI pow(int n) const { // a^n % MOD MI pm = 1, a = *this; while (n > 0) { if (n & 1) pm *= a; a *= a; n >>= 1; } return pm; } MI inv() const { return pow(MOD - 2); } MI operator/(const MI m) const { return *this * m.inv(); } MI &operator/=(const MI m) { return (*this = *this / m); } }; typedef MI mi; /* global variables */ int bs[MAX_N], pcs[MAX_N]; mi fs[MAX_N + 1], invfs[MAX_N + 1]; /* subroutines */ inline mi nck(int n, int k) { // nCk % MOD return fs[n] * invfs[n - k] * invfs[k]; } void prepare_fracs(int n) { fs[0] = invfs[0] = 1; for (int i = 1; i <= n; i++) { fs[i] = fs[i - 1] * i; invfs[i] = fs[i].inv(); } } inline int de2(int a) { if (a <= 0) return 0; int c = 0; while (! (a & 1)) c++, a >>= 1; return c; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", bs + i); pcs[0] = 0; for (int i = 1; i < n; i++) pcs[i] = pcs[i - 1] + de2(n - i) - de2(i); //for (int i = 0; i < n; i++) printf("%d ", pcs[i]); putchar('\n'); int on = 0, en = 0, x = 0; for (int i = 0; i < n; i++) { if (bs[i] < 0) { if (pcs[i] == 0) on++; else en++; } else x ^= (pcs[i] == 0 ? 1 : 0) * bs[i]; } //printf("on=%d, en=%d, x=%d\n", on, en, x); prepare_fracs(n); mi sum = 0; for (int i = x ^ 1; i <= on; i += 2) sum += nck(on, i); sum *= mi(2).pow(en); printf("%d\n", sum.v); return 0; }