F. Famous Classic Problem
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Given an array $$$a$$$, find the largest sum of a (possibly empty) subarray.

Input

The input consists of:

  • One line with one integer $$$n$$$ ($$$1 \leq n \leq 3 \cdot 10^5$$$), the length of the array.
  • One line with $$$n$$$ integers $$$x_i$$$ ($$$1 \leq \left\vert x_i \right\vert \leq 10^9$$$). If $$$x_i \gt 0$$$, this means that $$$a_i = 2^{x_i}$$$. Otherwise, $$$a_i = - 2^{-x_i}$$$.
Output

Output one integer, the answer modulo $$$998244353$$$.

Examples
Input
5
2 -3 4 -1 3
Output
22
Input
1
-1
Output
0