#arc160c. [arc160_c]Power Up

[arc160_c]Power Up

Problem Statement

You are given a multiset of positive integers with NN elements: A=lbraceA1,A2,dots,ANrbraceA=\\lbrace A_1,A_2,\\dots,A_N \\rbrace.

You may repeat the following operation any number of times (possibly zero).

  • Choose a positive integer xx that occurs at least twice in AA. Delete two occurrences of xx from AA, and add one occurrence of x+1x+1 to AA.

Find the number, modulo 998244353998244353, of multisets that AA can be in the end.

Constraints

  • 1leNle2times1051 \\le N \\le 2 \\times 10^5
  • 1leAile2times1051 \\le A_i \\le 2 \\times 10^5

Input

The input is given from Standard Input in the following format:

NN A1A_1 A2A_2 dots\\dots ANA_N

Output

Print the answer.


Sample Input 1

4
1 1 2 4

Sample Output 1

3

AA can be one of the three multisets $\\lbrace 1,1,2,4 \\rbrace,\\lbrace 2,2,4 \\rbrace,\\lbrace 3,4 \\rbrace$ in the end.

You can make A=lbrace3,4rbraceA = \\lbrace 3,4 \\rbrace as follows.

  • Choose x=1x = 1. Delete two 11s from AA and add one 22 to AA, making A=lbrace2,2,4rbraceA=\\lbrace 2,2,4 \\rbrace.
  • Choose x=2x = 2. Delete two 22s from AA and add one 33 to AA, making A=lbrace3,4rbraceA=\\lbrace 3,4 \\rbrace.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

1

Sample Input 3

13
3 1 4 1 5 9 2 6 5 3 5 8 9

Sample Output 3

66