#abc150e. [abc150_e]Change a Little Bit

[abc150_e]Change a Little Bit

Problem Statement

For two sequences SS and TT of length NN consisting of 00 and 11, let us define f(S,T)f(S, T) as follows:

  • Consider repeating the following operation on SS so that SS will be equal to TT. f(S,T)f(S, T) is the minimum possible total cost of those operations.

    • Change SiS_i (from 00 to 11 or vice versa). The cost of this operation is DtimesCiD \\times C_i, where DD is the number of integers jj such that SjneqTj(1leqjleqN)S_j \\neq T_j (1 \\leq j \\leq N) just before this change.

There are 2Ntimes(2N1)2^N \\times (2^N - 1) pairs (S,T)(S, T) of different sequences of length NN consisting of 00 and 11. Compute the sum of f(S,T)f(S, T) over all of those pairs, modulo (109+7)(10^9+7).

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2 \\times 10^5
  • 1leqCileq1091 \\leq C_i \\leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN C1C_1 C2C_2 cdots\\cdots CNC_N

Output

Print the sum of f(S,T)f(S, T), modulo (109+7)(10^9+7).


Sample Input 1

1
1000000000

Sample Output 1

999999993

There are two pairs (S,T)(S, T) of different sequences of length 22 consisting of 00 and 11, as follows:

  • S=(0),T=(1):S = (0), T = (1): by changing S1S_1 to 11, we can have S=TS = T at the cost of 10000000001000000000, so f(S,T)=1000000000f(S, T) = 1000000000.
  • S=(1),T=(0):S = (1), T = (0): by changing S1S_1 to 00, we can have S=TS = T at the cost of 10000000001000000000, so f(S,T)=1000000000f(S, T) = 1000000000.

The sum of these is 20000000002000000000, and we should print it modulo (109+7)(10^9+7), that is, 999999993999999993.


Sample Input 2

2
5 8

Sample Output 2

124

There are 1212 pairs (S,T)(S, T) of different sequences of length 33 consisting of 00 and 11, which include:

  • S=(0,1),T=(1,0)S = (0, 1), T = (1, 0)

In this case, if we first change S1S_1 to 11 then change S2S_2 to 00, the total cost is 5times2+8=185 \\times 2 + 8 = 18. We cannot have S=TS = T at a smaller cost, so f(S,T)=18f(S, T) = 18.


Sample Input 3

5
52 67 72 25 79

Sample Output 3

269312