#arc116b. [arc116_b]Products of Min-Max

[arc116_b]Products of Min-Max

Problem Statement

Given is a sequence AA of NN integers. There are 2N12^N - 1 non-empty subsequences BB of AA. Find the sum of $\\max\\left(B\\right) \\times \\min\\left(B\\right)$ over all of them.

Since the answer can be enormous, report it modulo 998244353998244353.

Constraints

  • All values in input are integers.
  • 1leqNleq2times1051 \\leq N \\leq 2 \\times 10^5
  • 0leqAileq9982443520 \\leq A_i \\leq 998244352

Input

Input is given from Standard Input in the following format:

NN A1A_1 A2A_2 cdots\\cdots ANA_N

Output

Print the answer.


Sample Input 1

3
2 4 3

Sample Output 1

63

There are 77 subsequences BB, as follows:

  • B=left(2right)B = \\left(2\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 4$
  • B=left(4right)B = \\left(4\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 16$
  • B=left(3right)B = \\left(3\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 9$
  • B=left(2,4right)B = \\left(2, 4\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 8$
  • B=left(2,3right)B = \\left(2, 3\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 6$
  • B=left(4,3right)B = \\left(4, 3\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 12$
  • B=left(2,4,3right)B = \\left(2, 4, 3\\right) : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 8$

The answer is the sum of them: 6363.


Sample Input 2

1
10

Sample Output 2

100

Sample Input 3

7
853983 14095 543053 143209 4324 524361 45154

Sample Output 3

206521341