AT_agc041_f [AGC041F] Histogram Rooks
Description
Let us consider a grid of squares with $N$ rows and $N$ columns. Arbok has cut out some part of the grid so that, for each $i = 1, 2, \ldots, N$, the bottommost $h_i$ squares are remaining in the $i$\-th column from the left. Now, he wants to place rooks into some of the remaining squares.
A rook is a chess piece that occupies one square and can move horizontally or vertically, through any number of unoccupied squares. A rook can not move through squares that have been cut out by Arbok.
Let's say that a square is covered if it either contains a rook, or a rook can be moved to this square in one move.
Find the number of ways to place rooks into some of the remaining squares so that every remaining square is covered, modulo $998244353$.
Input Format
Input is given from Standard Input in the following format:
> $N$
>
> $h_1$ $h_2$ $...$ $h_N$
Output Format
Print the number of ways to place rooks into some of the remaining squares so that every remaining square is covered, modulo $998244353$.
Explanation/Hint
### Constraints
- $1 \leq N \leq 400$
- $1 \leq h_i \leq N$
- All input values are integers.
### Sample Explanation 1
Any placement with at least two rooks is fine. There are $11$ such placements.
### Sample Explanation 2
The following $17$ rook placements satisfy the conditions (`R` denotes a rook, `*` denotes an empty square):
```
R * * R * * R R R R R R
**R R** R*R R** *R* **R
R * R * * R * R * * R R
R*R *RR RR* R*R RRR RR*
R R R R R * * R R R
R*R *RR RRR RRR RRR
```