Problem9003--[yosupo] Enumerative Combinatorics - Number of Subsequences

9003: [yosupo] Enumerative Combinatorics - Number of Subsequences

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You are given an integer sequence $A$ with length $N$. Count the number of distinct subsequence of $A$ , modulo $998244353$.

Input

$N$
$A_0$ $A_1$ $\dots$ $A_{N - 1}$

Constraints

$1 \leq N \leq 5 \times 10^5$
$0 \leq A_i \leq 10^9$

Sample 1 Input

5
0 0 0 1 1

Sample 1 Output

11

Sample 2 Input

9
9 9 8 2 4 4 3 5 3

Sample 2 Output

251

HINT

相同题目:yosupo

Source/Category