{"raw_statement":[{"iden":"problem statement","content":"Given is a sequence $A$ of $N$ numbers.\nThere are $2^{N-1}$ ways to divide $A$ into non-empty **contiguous** subsequences $B_1,B_2,\\ldots,B_k$. Find the value below for each of those ways, and print the sum, modulo $998244353$, of those values.\n\n*   $\\prod_{i=1}^{k} (\\max(B_i)-\\min(B_i))$\n\nHere, for a sequence $B_i=(B_{i,1},B_{i,2},\\ldots,B_{i,j})$, $\\max(B_i)$ and $\\min(B_i)$ are defined to be the maximum and minimum values of an element of $B_i$, respectively."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 3 \\times 10^5$\n*   $1 \\leq A_i \\leq 10^9$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"3\n1 2 3"},{"iden":"sample output 1","content":"2\n\nThere are $4$ ways to divide $A=(1,2,3)$ into non-empty contiguous subsequences, as follows.\n\n*   $(1)$, $(2)$, $(3)$\n*   $(1)$, $(2,3)$\n*   $(1,2)$, $(3)$\n*   $(1,2,3)$\n\n$\\prod_{i=1}^{k} (\\max(B_i)-\\min(B_i))$ for these divisions are $0$, $0$, $0$, $2$, respectively. The sum of them, $2$, should be printed."},{"iden":"sample input 2","content":"4\n1 10 1 10"},{"iden":"sample output 2","content":"90"},{"iden":"sample input 3","content":"10\n699498050 759726383 769395239 707559733 72435093 537050110 880264078 699299140 418322627 134917794"},{"iden":"sample output 3","content":"877646588\n\nBe sure to print the sum modulo $998244353$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}