#P7837. Expectation
Expectation
Expectation
Problem Description
Notice:Don't output extra spaces at the end of one line. There are distinct positions on the number line, in the strictly increasing order. each position with odd index is a hole and each postition with even index is a ball. Koishi will play a game consisting of rounds, in each round: 1.Koishi selects a ball that isn't in holes at random. 2.then select the direction,left or right at random. 3.then the chosen ball starts rolling in that chosen direction, until it falls into an empty hole(the hole with no ball falling into it before) Koishi is interested in the sum of distances of balls rolling. What is the expected value of the sum? modulo
Input
First line contains an integer , number of test cases. In each test cases, the first line contains an integer . The second line contains integers in a single line representing
Output
lines, each with a non-negative integer representing the answer.
Sample Input
3
1
1 2 3
3
1 2 3 4 5 6 7
10
0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210
Sample Output
1
332748122
969129126
Source
2020 Multi-University Training Contest 7