Consecutive Neighbours


A uniformly random permutation π\pi of 1,2,…,n1, 2, \ldots, n is generated. For each i=1,2,…,n−1i = 1, 2, \ldots, n - 1, if the values ii and i+1i + 1 appear in adjacent positions of π\pi, you score wiw_i.

Let XX be the total score. Output the expected value of XX.

It can be shown that the answer can be expressed as a rational number P/QP/Q in lowest terms with QQ coprime to 109+710^9 + 7. Output P⋅Q−1 mod (109+7)P \cdot Q^{-1} \bmod (10^9 + 7).

Input

The first line contains an integer nn.

The second line contains n−1n - 1 integers w1,w2,…,wn−1w_1, w_2, \ldots, w_{n-1}. If n=1n = 1, this line is empty.

Output

Print a single integer: the expected total score modulo 109+710^9 + 7.

Constraints

  • 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5
  • 0≤wi≤1090 \le w_i \le 10^9

Example 1

Input 1
3
1 1
Output 1
333333337
Explanation

There are two pairs, (1,2)(1, 2) and (2,3)(2, 3). Each pair of consecutive values occupies adjacent positions with probability 2/32/3, so the expected score is 4/34/3. 4⋅3−1≡333333337(mod109+7)4 \cdot 3^{-1} \equiv 333333337 \pmod{10^9 + 7}.

Example 2

Input 2
2
10
Output 2
10
Explanation

The two values are always adjacent, so the score is always 1010.

Example 3

Input 3
1
Output 3
0
Explanation

There are no consecutive pairs when n=1n = 1.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.