Problem Statement
There are $N$ points numbered $1,2, \dots, N$ on the $2$-dimensional plane. The coordinates of point $i$ are $(i,Y_i)$. In this problem, it is guaranteed that $Y=(Y_1,Y_2,\dots ,Y_N)$ is a permutation of $(1,2, \dots ,N)$.
Find the sum of the areas of bounding boxes for all subsets $S$ of $\lbrace \texttt{point}\,1,\texttt{point}\,2,\dots ,\texttt{point}\,N \rbrace$ with at least $2$ elements, modulo $998244353$.
The bounding box for $S$ refers to the minimum area rectangle with sides parallel to the $x$-axis that contains all points in $S$ inside or on the boundary.
Constraints
$2 \le N \le 2 \times 10^5$$Y$is a permutation of$(1,2, \dots ,N)$.- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
Y_1 Y_2 \ldots Y_N
Output
Output the sum, modulo $998244353$, of the areas of bounding boxes.
样例
4
2 3 1 4
50
26
6 14 8 19 13 25 26 22 7 3 16 15 11 24 1 12 20 23 5 17 9 2 21 10 4 18
575187918
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。