Expected Fixed Points


There are nn people and nn gifts, labelled 11 through nn. The gifts are handed out according to a uniformly random permutation: every permutation of the nn gifts is equally likely.

Person ii receives value wiw_i if they get gift ii, and otherwise receives 00. Let XX be the total value received by everyone.

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 nn integers w1,w2,…,wnw_1, w_2, \ldots, w_n.

Output

Print a single integer: the expected total value 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 2 3
Output 1
2
Explanation

The expected value is (1+2+3)/3=2(1 + 2 + 3)/3 = 2.

Example 2

Input 2
1
7
Output 2
7
Explanation

There is only one permutation, so person 11 always receives gift 11.

Example 3

Input 3
2
5 5
Output 3
5
Explanation

Each person gets their own gift with probability 1/21/2, so the expected total is 5/2+5/2=55/2 + 5/2 = 5.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.