Universal Cup Judging System

Universal Cup

حد الوقت: 2.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

A Young diagram is a finite set of cells, arranged in left-aligned rows, with the row lengths in non-increasing order. It can be uniquely represented by an unordered integer partition $\lambda = (\lambda_1, \lambda_2, \dots, \lambda_r)$ satisfying $\lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_r \ge 1$, where $r$ corresponds to the number of rows of the Young diagram, and $\lambda_i$ corresponds to the number of cells in the $i$-th row for $i = 1, 2, \dots, r$.

The conjugate of a Young diagram $\lambda$ is another Young diagram obtained by transposing rows and columns, represented by the conjugate partition $\lambda^T$. More specifically, if $\lambda$ has $c = \lambda_1$ columns, then $\lambda^T = (\mu_1, \mu_2, \dots, \mu_c)$ where $\mu_j = |\{ i : \lambda_i \ge j \}|$ for $j = 1, 2, \dots, c$.

For a cell at the $i$-th row and the $j$-th column that belongs to $\lambda$, let the subdiagram anchored at $(i, j)$ be the set of all cells $(x, y)$ of $\lambda$ with $x \ge i$ and $y \ge j$. It is easy to see that, this set is itself a Young diagram when viewed with $(i, j)$ as its top-left corner.

Define the cuteness of a Young diagram $\lambda$ as the number of distinct Young diagrams that can be obtained from $\lambda$ by performing the following operation any number (possibly zero) of times: choose any cell $(i, j)$ of the current Young diagram, take the subdiagram anchored at $(i, j)$, and replace it with its conjugate anchored at the same position. The operation is allowed if and only if the overall set of cells still forms a valid Young diagram; otherwise the operation is denied and undone, as illustrated below.

Figure 1

You are given a non-increasing sequence of positive integers $a_1, a_2, \dots, a_n$. For each $i = 1, 2, \dots, n$, compute the cuteness of the Young diagram $\lambda^{(i)}$, modulo $998\,244\,353$, where $\lambda^{(i)} = (a_1, a_2, \dots, a_i)$.

Input

The first line contains a single integer $n$ ($1 \le n \le 10^6$), denoting the length of the given sequence.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$). It is guaranteed that $a_1 \ge a_2 \ge \dots \ge a_n$.

Output

Output $n$ integers separated by spaces, where the $i$-th integer represents the cuteness of the Young diagram $\lambda^{(i)}$, modulo $998\,244\,353$.

Examples

Input 1

3
3 2 1

Output 1

2 3 1

Note

For the sample case:

  • The distinct Young diagrams that can be obtained from $\lambda^{(1)}$ are $(3)$ and $(1, 1, 1)$;
  • The distinct Young diagrams that can be obtained from $\lambda^{(2)}$ are $(3, 2)$, $(3, 1, 1)$, and $(2, 2, 1)$;
  • The only Young diagram that can be obtained from $\lambda^{(3)}$ is $(3, 2, 1)$ itself.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.