#arc116b. [arc116_b]Products of Min-Max
[arc116_b]Products of Min-Max
Problem Statement
Given is a sequence of integers. There are non-empty subsequences of . 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 .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
2 4 3
Sample Output 1
63
There are subsequences , as follows:
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 4$
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 16$
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 9$
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 8$
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 6$
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 12$
- : $\\max\\left(B\\right) \\times \\min\\left(B\\right) = 8$
The answer is the sum of them: .
Sample Input 2
1
10
Sample Output 2
100
Sample Input 3
7
853983 14095 543053 143209 4324 524361 45154
Sample Output 3
206521341