#include #include int cmp_int (const void *ap, const void *bp) { int a = *(int *)ap; int b = *(int *)bp; if (a < b) { return -1; } if (a > b) { return 1; } return 0; } int main () { int n = 0; int a = 0; int res = 0; long long dp[200001][31] = {}; long long mod_num = 998244353LL; int prev[30] = {}; res = scanf("%d", &n); dp[0][30] = 1LL; for (int i = 0; i < n; i++) { int prev_sort[31][2] = {}; res = scanf("%d", &a); for (int j = 0; j < 30; j++) { if ((a&(1< 0) { dp[i+1][j] = dp[i][30]; prev[j] = i+1; } else { dp[i+1][j] = dp[i][j]; } prev_sort[j][0] = prev[j]; prev_sort[j][1] = j; } prev_sort[30][0] = -1; qsort(prev_sort, 31, sizeof(int)*2, cmp_int); dp[i+1][30] = 0LL; for (int j = 0; j < 30; j++) { if (prev_sort[j][0] != prev_sort[j+1][0]) { dp[i+1][30] += dp[i+1][prev_sort[j+1][1]]; dp[i+1][30] %= mod_num; } dp[i+1][prev_sort[j+1][1]] = dp[i+1][30]; } if (dp[i+1][30] == 0LL) { dp[i+1][30] = 1LL; } } printf("%lld\n", dp[n][30]); return 0; }