Game

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Now, you are playing a simple game. Given an array AA of length nn, your task is to control a robot to move or stop in this array.

Initially, the position of the robot is randomly selected: the probability for selecting position i\[1,n]i \in \[1, n] is 1n\frac{1}{n}. In each turn, you know the current position, and need to make a decision between two action choices:

  • Stop. If this action is selected, the game ends immediately. When the robot stops at position ii, your score is A_iA\_i.
  • Move. If this action is selected and the robot is at position ii, with a 5050\\% chance, the robot will move to i1i - 1, and with another 5050\\% chance, it will move to i+1i + 1. Note that when the robot is at position 11 or nn, you cannot select this action.

Since the second action can be selected only when the robot is not at either end of the array, we can prove that, for any strategy, lim_m+f(m)=0\lim\limits\_{m \rightarrow +\infty} f(m) = 0, where f(m)f(m) represents the probability that the game continues after mm turns.

Your task is to maximize the expected score of the game.

입력

The first line contains a single integer nn (1n51051 \le n \le 5 \cdot 10^5).

The second line contains nn integers A_1,A_2,,A_nA\_1, A\_2, \ldots, A\_n (1A_i10121 \le A\_i \le 10^{12}).

출력

Output a single line with a single integer: the maximum possible expected score as a fraction modulo 998,244,353998\\,244\\,353. In other words, it can be proven that the answer can be expressed as a rational number P/QP / Q where QQ is coprime with 998,244,353998\\,244\\,353, and you must output (PQ1)mod998,244,353(P \cdot Q^{-1}) \bmod 998\\,244\\,353.