For two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:
 - Consider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations.
 - Change S_i (from 0 to 1 or vice versa). The cost of this operation is D \times C_i, where D is the number of integers j such that S_j \neq T_j (1 \leq j \leq N) just before this change.
There are 2^N \times (2^N - 1) pairs (S, T) of different sequences of length N consisting of 0 and 1. Compute the sum of f(S, T) over all of those pairs, modulo (10^9+7).

-----Constraints-----
 - 1 \leq N \leq 2 \times 10^5
 - 1 \leq C_i \leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
C_1 C_2 \cdots C_N

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

-----Sample Input-----
1
1000000000

-----Sample Output-----
999999993

There are two pairs (S, T) of different sequences of length 2 consisting of 0 and 1, as follows:
 - S = (0), T = (1): by changing S_1 to 1, we can have S = T at the cost of 1000000000, so f(S, T) = 1000000000.
 - S = (1), T = (0): by changing S_1 to 0, we can have S = T at the cost of 1000000000, so f(S, T) = 1000000000.
The sum of these is 2000000000, and we should print it modulo (10^9+7), that is, 999999993.

Difficulty: interview

Starter code:

Solutions:
mod = 10**9 + 7

def power(p, e):
  ret = 1
  while(e):
    if(e & 1):
      ret *= p
      ret %= mod
    p *= p
    e >>= 1
  return ret

N = int(input())
C = list(map(int, input().split()))
C.sort()

f = 0
for i in range(N):
  f += (N - i + 1) * C[i]
  f %= mod

f *= power(2, N - 1)**2 % mod
f %= mod
print(f)

#import sys
#sys.setrecursionlimit(10**5)
MOD = 10**9+7

# input
N = int(input())
C = list(map(int, input().split()))
    
# process
C.sort(reverse=True)
ans = 0

if N == 1:
    ans = C[0]*2**N
else:
    for i in range(N):
        ans += C[i]*(2+i)

    ans *= 4**(N-1)

# output
print((ans%MOD))


n=int(input())
C=list(map(int,input().split()))
C=sorted(C,reverse=True)
mod=10**9+7
a=pow(2,2*n-2,mod)
ans=0
for i in range(n):
  ans=ans+C[i]*(i+2)*a
print(ans%mod)

n = int(input())
c = sorted(map(int, input().split()))

mod = 1000000007

ret = 0
for i in range(n):
    ret = (ret + (i + 2) * c[n - i - 1]) % mod

for i in range(n - 1):
    ret = (ret * 4) % mod

print(ret)


def solve():
  ans = 0
  N = int(input())
  C = list(map(int, input().split()))
  C.sort()
  mod = 10**9+7
  for i in range(N):
    ans += C[i]*(N+1-i)
  ans = ans*pow(2,2*N-2,mod)%mod
  return ans
print(solve())

N = int(input())
C = list(map(int, input().split()))
C.sort(reverse =  True)

MOD = 10 ** 9 + 7

if N == 1:
    print (2 * C[0] % MOD)
    return

start = pow(2, N - 1, MOD)
step = pow(2, N - 2, MOD)
ans = 0
for c in C:
    ans += c * start
    ans %= MOD
    start += step
    start %= MOD

ans *= pow(2, N, MOD)
ans %= MOD

print (ans)

MOD = 10**9 + 7

N = int(input())
Cs = list(map(int, input().split()))

Cs.sort(reverse=True)

pow2 = pow(2, 2*N-2, MOD)

ans = 0
for i, C in enumerate(Cs, start=1):
    ans += C*(i+1)*pow2
    ans %= MOD

print(ans)


mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=0
for i in range(n):
  ans+=pow(2,2*n-2,mod)*(n-i+1)*arr[i]
  ans%=mod
print(int(ans))

N = int(input())
C = list(map(int,input().split()))
for i in range(N):
    C[i] *= -1
C.sort()
for i in range(N):
    C[i] *= -1
mod = 10**9 + 7
ans = 0
for i in range(N):
    ans += C[i]*(i+2)
ans = ans*(4**(N-1))
ans = ans % mod
print(ans)

N = int(input())
C = [0] + sorted(list(map(int, input().split())))
MOD = 10 ** 9 + 7

ans = 0
for i in range(1, N + 1):
    l, r = i - 1, N - i
    ans += C[i] * pow(2, l, MOD) * (pow(2, max(0, r - 1), MOD) * r % MOD + pow(2, r, MOD)) % MOD

print((ans * pow(2, N, MOD) % MOD))


n=int(input())
c=list(map(int,input().split()))
mod=10**9+7
c.sort(reverse=True)
ans=0
po2=[1]
for i in range(n):
    po2.append(po2[-1]*2%mod)
for i,j in enumerate(c,1):
    ans+=j*((i-1)*po2[i-2]+po2[i-1])*po2[n-i]*po2[n-i]*po2[i]%mod
    ans%=mod
print(ans)

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
M = 10**9+7

pp = [None]*n
v = 1
for i in range(n):
    pp[i] = v
    v *= 2
    v %= M

a.sort()
a = a[::-1]
ans = 0
ans += a[0]*(pow(2, 0, M))*pow(2, n-1,M)
for i in range(1,n):
    num = a[i]
    ans += num*(pp[i] + i*pp[i-1])*pp[n-i-1]
    ans %= M
ans *= pow(2,n,M)
ans %= M
print(ans)

n = int(input())
mod = 10 ** 9 + 7
c = list(map(int, input().split()))
c.sort()

ans = 0
for i in range(n):
    if i < n - 1:
        ans += c[i] * (n - i + 1) * pow(2, n - i - 2, mod) * pow(2, i, mod)
        ans %= mod

    else:
        ans += c[i] * pow(2, n - i - 1, mod) * pow(2, i, mod)
        ans %= mod


ans *= pow(2, n, mod)
ans %= mod

print(ans)

import sys
input = sys.stdin.readline
from math import factorial

def comb(a,d):
    return factorial(a)//factorial(b)//factorial(a-b)

mod = 10**9+7

N = int(input())
C_input = list(map(int, input().split()))

C = sorted(C_input)
ans = 0
for ind, s in enumerate(C):
    ans+= C[ind] * (N+1-ind)
    ans %= mod
print(int(ans* 2**(2*N-2)) %mod)

N = int(input())
C = sorted(map(int, input().split()))
mod = 10**9+7
# そのビットが異なる確率 * それ以上のビットが立っている数の期待値 * c
ans = 0
for i, c in enumerate(C[::-1], 2):
    ans += i * c
ans %= mod
ans = ans * pow(2, 2*N-2, mod) % mod
print(ans)


N = int(input())
MOD = 10**9 + 7
C = list(map(int, input().split()))
C.sort()

ans = 0
for i, c in enumerate(C, start=1):
    M = N - i
    ans += c * (M + 2)
    ans %= MOD
ans *= pow(4, N - 1, MOD)
print((ans % MOD))


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    mod = 10**9 + 7

    n = int(input())
    c = list(map(int, input().split()))
    c.sort()
    res = 0
    b = pow(2, n, mod)
    for i in range(n):
        l = pow(2, i, mod)
        if n-i-2 >= 0:
            r = pow(2, n-i-1, mod) + (n-i-1)*pow(2, n-i-2, mod)
        else:
            r = pow(2, n-i-1, mod)
        res += b*c[i]*l*r % mod
        res %= mod
    print(res)

def __starting_point():
    main()

__starting_point()

import sys
INF=1e9
mod=1e9+7
n=int(input())
lit=list(map(int,input().split()))
lit.sort()
ans=0
for i in range(n):
    ans=(ans+lit[i]*(n-i+1)%mod)%mod
for i in range((n-1)):
    ans=ans*4%mod
ans=int(ans)
print(ans)


N = int(input())
C = [int(c) for c in input().split()]
C.sort()
MOD = 10**9+7
p2 = [1]
for i in range(2*N+10):
  p2 += [p2[-1]*2%MOD]

ans = 0
for i in range(N):
  m = (p2[N-1-i]+(N-i-1)*p2[N-i-2])*C[i]
#  print(m)
  m = m*p2[N+i]%MOD
  ans += m
print((ans%MOD))


n = int(input())
c = list(map(int, input().split()))
mod = 10**9+7
c.sort(reverse=True)
ans = 0
for k, num in enumerate(c):
    ans += (k+2)*num
    ans %= mod

for _ in range(2*n-2):
    ans *= 2
    ans %= mod

print(ans)

n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists,reverse=True)

mod=10**9+7
dp=[0 for i in range(n+1)]
dp[1]=2*lists[0]
for i in range(1,n):
    x=lists[i]
    y=pow(2,i,mod)
  
    dp[i+1]=4*dp[i]+(i+2)*(y**2)*lists[i]
    dp[i+1]%=mod

print(dp[n]%mod)


def resolve():
    MOD = 10 ** 9 + 7
    N = int(input())
    C = sorted(map(int, input().split()))
    P = [1] * (N + 1)
    for i in range(N):
        P[i + 1] *= P[i] * 2
        P[i + 1] %= MOD
    ans = 0
    for i in range(N):
        # 各ビットの係数: (2^r + 2^r-1 * r) * 2^l
        l, r = i, N - i - 1
        now = P[r]
        if r != 0:
            now += P[r - 1] * r
        now *= P[l]
        now *= C[i]
        ans += now
        ans %= MOD
    ans *= P[N]
    print(ans % MOD)


def __starting_point():
    resolve()
__starting_point()

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# テスト用コード
# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
# N-2がマイナスになる時に注意、一番右は2**(N-1)
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() % MOD
answer *= pow(2, N, MOD)
print((answer%MOD))


def main():
    n=int(input())
    c=sorted(list(map(int,input().split())))
    mod=10**9+7
    ans=0
    for i,j in enumerate(c):
        ans=(ans+j*(n-i+1))%mod
        
    ans=(ans*4**(n-1))%mod
    print(ans)

def __starting_point():
    main()
__starting_point()

# 解説放送

def pow2(n, mod):
    """2のn乗まで"""
    t = 1
    yield t
    for _ in range(n):
        t = t * 2 % mod
        yield t


def main():
    MOD = 10 ** 9 + 7

    N = int(input())
    *c, = list(map(int, input().split()))

    c.sort()

    *two, = pow2(N, MOD)

    ans = 0
    for l, x in enumerate(c):
        # x:=係数.この位置の操作にかかるコストの総和を求める.
        # r:=xの右側にある要素数
        # (1<<r)個の状態を行として並べて,列で不一致数を確認すると,どの列も状態の半分が不一致.これがr列ある.
        r = N - l - 1

        t = two[r]
        if r != 0:
            t += two[r - 1] * r  # 右側の個数
        t = t * two[l] % MOD
        t = t * x % MOD
        ans += t

    ans = ans * two[N] % MOD
    print(ans)


def __starting_point():
    main()

__starting_point()

mod = 10**9 + 7
n = int(input())
c = list(map(int,input().split()))
c.sort(reverse = True)
ans = 0
for i in range(n):
    ans += c[i]*(i+2) 
    ans %= mod
ans *= pow(4,n-1,mod)
ans %= mod
print(ans)

N = int(input())
C = list(map(int, input().split()))
MOD = 1_000_000_007

B = [0 for _ in range(N+1)]#2べきmod
B[0] = 1
for i in range(1,N+1):
  B[i] = B[i-1] * 2
  B[i] %= MOD  

C.sort()

ans = 0
for n in range(1,N+1):
  ans += C[n-1] * ((N-n) * B[N-n-1] + B[N-n]) * B[n-1]
  ans %=  MOD
  
ans *= B[N]
ans %= MOD

print(ans)

"""
D = [0 for _ in range(N)]#累積和
D[0] = C[0]
for i in range(1,N):
  D[i] = D[i-1] + C[i]
print(C)

  
ans = 0
for j in range(1,N+1):
  ans += D[j-1] * B[j-1]  
  print(D[j-1] * B[j-1]  
  
"""

n = int(input())
c = list(map(int, input().split()))
mod = 10 ** 9 + 7

c.sort(reverse=True)
ans = 0
for i, e in enumerate(c):
    ans += e * (2 + i)
    ans %= mod

ans *= pow(2, 2 * n - 2, mod)
ans %= mod

print(ans)


N=int(input());c=sorted(list(map(int,input().split())));m=10**9+7;print(sum([c[i]*(N-i+1)*pow(4,N-1,m) for i in range(N)])%m)

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, C: "List[int]"):
    pows = [1]
    for i in range(N):
        pows.append(pows[i] * 2 % MOD)

    C.sort(reverse=True)
    ret = 0
    for i, v in enumerate(C):
        if i > 0:
            ret += (pows[i] + pows[i - 1] * i) * (pows[N - i - 1]) * v
        else:
            ret += pows[i] * (pows[N - i - 1]) * v
    ret = ret * pows[N] % MOD
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)

def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = 10 ** 15
from heapq import  heapify,heappop,heappush


def main():
    N = int(input())
    C = list(map(int,input().split()))
    C.sort()
    
    power = [1]
    for i in range(N):
        power.append(power[-1]*2%MOD)

    ans = 0
    for i,c in enumerate(C):
        ans += c*(power[N - 2]*power[N]*(N - i - 1))%MOD
        ans += c*(power[N - 1]*power[N])%MOD
        ans %= MOD
    print(ans)
def __starting_point():
    main()
__starting_point()

n = int(input())
c = sorted(list(map(int, input().split())))
p = 10 ** 9 + 7

print(((sum([(n + 2 - i) * ci for i, ci in enumerate(c, 1)]) * pow(4, n - 1, p)) % p))


n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10 ** 9 + 7
ans = 1
for _ in range(2*n-2):
  ans *= 2
  ans %= mod
cef = [i+2 for i in range(n)]
for i in range(n):
  a[i] *= cef[i]
ans *= sum(a)
ans %= mod
print(ans)

N,*C = map(int, open(0).read().split())
MOD = 10**9+7
p2 = [1]*(2*N+1)
for i in range(1,2*N+1):
  p2[i] = p2[i-1]*2%MOD
C.sort()
ans = 0
for i,c in enumerate(C):
  n = N-1-i
  ans += c*(n*p2[n-1]+p2[n])*p2[N+i]%MOD
print(ans%MOD)

import sys
INF=1e9
mod=1e9+7
n=int(input())
lit=list(map(int,input().split()))
lit.sort()
ans=0
for i in range(n):
    ans=(ans+lit[i]*(n-i+1)%mod)%mod
for i in range(2*(n-1)):
    ans=ans*2%mod
ans=int(ans)
print(ans)


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    C = list(map(int, input().split(' ')))
    C.sort()
    pow_2 = 1  # 2 ** (2 * N - 2)
    for _ in range(2 * N - 2):
        pow_2 *= 2
        pow_2 %= MOD
    ans = 0
    for k, c in enumerate(C):
        ans += c * ((N - k + 1) * pow_2)
        ans %= MOD
    print(ans)


def __starting_point():
    main()
__starting_point()

def solve():
  ans = 0
  N = int(input())
  C = list(map(int, input().split()))
  C.sort()
  mod = 10**9+7
  for i in range(N):
    ans += C[i]*(N+1-i)
  ans = ans*pow(2,2*N-2)%mod
  return ans
print(solve())

mod=10**9+7
def A001792(n):
  if n>1:
    return (n+1)*pow(2,n-2,mod)
  else:
    return 1

nn=int(input())
C=list(map(int, input().split()))
C.sort(reverse=True)
mod=10**9+7
ans=0
for i in range(nn):
  ans+=pow(2,nn-i-1,mod)*A001792(i+1)*C[i]
  ans %=mod
ans = ans*pow(2,nn,mod)
ans %=mod
print(ans)

N=int(input())
c=list(map(int,input().split()))
c.sort()
m=10**9+7
ans=0
for i in range(N):
    ans+=(c[i]*(N-i+1)*pow(2,(N-2)%(m-1),m))%m
print((ans*pow(2,N,m))%m)

def solve():
  ans = 0
  N = int(input())
  C = list(map(int, input().split()))
  C.sort()
  mod = 10**9+7
  for i in range(N):
    ans += C[i]*(N+1-i)
    ans %= mod
  ans = ans*pow(2,2*N-2,mod)%mod
  return ans
print(solve())

#E
n = int(input())
c = [int(i) for i in input().split()]
mod = 10**9+7

c.sort()
ans = 0
for i in range(n):
    ans += c[i]*(n-i+1)

ans *= 4**(n-1)
ans %= mod
print(ans)

####################################### Define
mod = int(1e9 + 7)
maxN = int(2e5 + 100)
pow = [1] * maxN
cost = []

####################################### Functions
def add(x, y) : return (x + y) % mod
def mul(x, y) : return x % mod * (y % mod) % mod
def prepare() :
    for i in range(1, maxN):
        pow[i] = mul(pow[i - 1], 2)
####################################### Main
prepare()
n = int(input())
inp = input().split()
for i in range(0, n) :
    cost.append( int(inp[i]))
cost.sort()

ans = 0
for i in range(1, n + 1) :
    cur = mul(pow[i - 1], mul(int(cost[i - 1]), pow[n - i]))
    if i < n : cur = add(cur, pow[i - 1] * pow[n - i - 1] % mod * int(cost[i - 1])
                          % mod * (n - i) % mod)
    ans = add(ans, cur)
print((mul(ans, pow[n])))
''' test
6
623 77 177 26 865 192
'''


N=int(input())
C=list(map(int,input().split()))
mod=10**9+7
C.sort()
C.reverse()
ans=0
for i in range(N):
  ans+=C[i]*(i+2)
  ans%=mod

p=pow(4,N-1,mod)
ans=ans*p%mod
print(ans)

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
M = 10**9+7
ans = 0
ans += a[0]*(pow(2, 0, M))*pow(2, n-1,M)
for i in range(1,n):
    num = a[i]
    ans += num*(pow(2, i, M) + i*pow(2,i-1,M))*pow(2,n-i-1,M)
    ans %= M
ans *= pow(2,n,M)
ans %= M
print(ans)

MOD = 1000000007

N = int(input())
C = list(map(int,input().split()))

C.sort(reverse=True)

ans = 0

for i in range(N):
    ans += C[i]*(2+i)*pow(4,N-1,MOD)
    ans %= MOD

print(ans)

mod = 10 ** 9 + 7

N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)

if N == 1:
    print(2 * C[0] % mod)
    return

ans = 0
coef = pow(2, N-1, mod)
for c in C:
    ans += c * coef
    ans %= mod
    coef = (coef + pow(2, N - 2, mod)) % mod

ans *= pow(2, N, mod)
ans %= mod
print(ans)

import numpy as np

n = int(input())
c = np.array(input().split(),dtype=int)
mod = 10**9+7

c = sorted(c)[::-1]
#4^(n-1)を求める
e4 = 1
k = n-1
inst = 4
while k > 0:
    if k%2 == 1:
        e4 = (e4*inst)%mod
    k = k//2
    inst = (inst**2)%mod

ans = 0
for i in range(n):
    ans = (ans+c[i]*(i+2))%mod
ans = (ans*e4)%mod

print(ans)


mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=0
total=pow(2,2*n-2,mod)
for i in range(n):
  ans+=total*(n-i+1)*arr[i]
  ans%=mod
print((int(ans)))


N = int(input())
C = list(map(int,input().split()))
C.sort(reverse=True)
MOD = 10**9+7
if N==1:
    print((C[0]*2)%MOD)
    return

ans = 0
d = pow(2,N-2,MOD)
base = pow(2,N-1,MOD)
for i,c in enumerate(C):
    ans += c * (base + i*d)
ans *= pow(2,N,MOD)
ans %= MOD
print(ans)

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() * 2**N
print((answer%MOD))


import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
# N-2がマイナスになる時に注意、一番右は2**(N-1)
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() * 2**N
print((answer%MOD))


import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
# N-2がマイナスになる時に注意、一番右は2**(N-1)
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() % MOD * pow(2, N, MOD)
print((answer%MOD))


N=int(input());c=sorted(list(map(int,input().split())));m=10**9+7;print(sum([c[i]*(N-i+1)*pow(2,2*N-2,m) for i in range(N)])%m)

# inverse x^(-1)
def inv(x):
    nonlocal mod
    return pow(x,mod-2,mod)

mod=10**9+7
N = int(input())
C = [0]
C.extend(sorted(list(map(int,input().split())), reverse=True)) # 1-indexed, 降順

# print(C)
# C[i]が最後からj番目に操作される（コストが C[i]*j 掛かる）のは，c[1]~C[i-1]にj-1個操作すべきもの，すなわち，C[i]以上のものがあるとき。
# C[i+1]~C[N]の選び方は自由。
# ⇒ combi(i-1, j-1)*2**(N-i) を掛ける。
# 総和を計算すると，結局，2**N * Σ[i=1->N](2**(N-i)*Ci*(2**(i-2)*(i-1) + 2**(i-1))) になる

pow2 = [1]
for k in range(1, N+1):    
    pow2.append(pow2[-1] * 2 % mod)

# print(pow2)

ans=0
for i in range(1, N+1):
    temp = pow2[N - i] * C[i] * ((0 if i == 1 else (pow2[i - 2] * (i - 1))) + pow2[i - 1]) % mod
    ans = (ans + temp) % mod

ans = ans * pow2[N] % mod

print(ans)

#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):

    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        fac = self.fac
        finv = self.finv
        mod = self.MOD
        return fac[n] * (finv[k]*finv[n-k] % mod) % mod


def solve(N: int, C: "List[int]"):

    ans = 0
    C.sort(reverse=True)
    for i, c in enumerate(C, start=1):
        b = c*(pow(2, 2*N-2, MOD)*(i+1)) % MOD
        ans += b
        ans %= MOD
    print((ans % MOD))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)


def __starting_point():
    main()

__starting_point()

n = int(input())
c = list(map(int, input().split()))
c.sort()
MOD = 1000000007
ans = 0
P = pow(4, n-1, MOD)
if n == 1:
  ans = c[0]*2 % MOD
else:
  for i in range(n):
    ans += P*c[i]*(n+1-i)
    ans %= MOD
 
print(ans)

N = int(input())
C = sorted(list(map(int,input().split())))[::-1]
ans = 0
MOD = 10**9 + 7
for k in range(N):
    ans += pow(2,2*N-2,MOD)*(k+2)*C[k]
print((ans%MOD))


N = int(input())
*C, = list(map(int, input().split()))
C.sort(reverse=True)
p = 10**9+7
S = 0
for i in range(N):
    S = (S+(i+2)*C[i]) % p
S = (S*pow(4, N-1, p)) % p
print(S)


n = int(input())
l = sorted(list(map(int,input().split())),reverse=True)
mod = 10**9+7

ans = 0

for i in range(n-1,-1,-1):
    ans += ((2+i)*l[i])
b = pow(2,2*n-2,mod)
print(ans*b%mod)

MOD = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort()

if N == 1:
    print (2 * C[0] % MOD)
    return

ANS = 0
for i, c in enumerate(C):
    ANS += c * (N + 1 - i)

ANS *= pow(2, N - 2, MOD)
ANS %= MOD
ANS *= pow(2, N, MOD)
print (ANS % MOD)

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    c = list(map(int, input().split()))
    mod = pow(10, 9) + 7
    
    c.sort(reverse=True)
    
    ans = 0
    
    for i in range(n):
        ans += (i+2) * c[i]
        ans %= mod
    
    ans *= pow(2, n*2-2, mod)
    ans %= mod
    
    print(ans)
    
    
def __starting_point():
    main()

__starting_point()

MOD = 10**9+7
n = int(input())
S = [1]*n
D = [1]*(n+1)
for i in range(n):
  D[i+1] = D[i]*2 % MOD
for i in range(n-1):
  S[i+1] = (S[i]*2 + D[i+1]) % MOD
T = S[::-1]
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
  ans += C[i]*((D[n-(i+1)]+T[i])*D[i]) % MOD
  ans %= MOD
ans = ans*D[n-1]%MOD
print(ans)

N = int(input())
mod = int(1e9) + 7
C = list(map(int, input().split()))
C.sort(reverse=True)
def doubling(n, m):
  y = 1
  base = n
  while m != 0:
    if m % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    m //= 2
  return y
b = 1
if N == 1:
  L, R = 0, 1
else:
  b = doubling(2, N-2)
  L, R = b, (2 * b) % mod
S1 = 0
S2 = 0
for i in range(N):
  S1 += (i * C[i]) % mod
  S1 %= mod
  S2 += C[i]
  S2 %= mod
print((doubling(2, N) * (S1 * L + S2 * R)) % mod)

MOD = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort()

if N == 1:
    print (2 * C[0] % MOD)
    return


lst = [0] * (N + 3)
lst[0] = 1
for i in range(1, N + 3):
    lst[i] = (lst[i - 1] * 2) % MOD


ANS = 0
for i, c in enumerate(C):
    ANS += c * (N + 1 - i)

ANS *= lst[N - 2]
ANS %= MOD
ANS *= lst[N] 
print (ANS % MOD)

from sys import stdin
f_i = stdin

mod = 10 ** 9 + 7

N = int(f_i.readline())

C = map(int, f_i.readline().split())
C = sorted(C)

x = (C_i * i % mod for i, C_i in zip(range(N + 1, 1, -1), C))

ans = pow(4, N - 1, mod) * sum(x) % mod

print(ans)

MOD=10**9+7
N=int(input())
clist=list(map(int,input().split()))
clist.sort()

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD

base=powmod(2,2*N-2)
coef=0
for i in range(N):
  coef+=clist[i]*(N+1-i)
  coef%=MOD

print(base*coef%MOD)

N = int(input())
C = list(map(int, input().split()))
C = reversed(sorted(C))

MOD = 10 ** 9 + 7
pow = 4 ** (N - 1) % MOD

ans = 0
for i, c in zip(range(N), C):
    ans += (i + 2) * c % MOD
    ans %= MOD

print(ans * pow % MOD)

n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
cost = 0
for i in range(1, n+1):
  cost = (cost + a[i-1]*(i+1)) % 1000000007
for i in range(1, n):
  cost = cost * 4 % 1000000007
print(cost)

MOD = 10**9 + 7

def main():
    n = int(input())
    c = list(map(int, input().split()))
    c.sort()
    ans = 0
    for i in range(n):
        tmp = pow(2, i, MOD)
        if i < n-1:
            tmp *= pow(2, n-i-1, MOD) + pow(2, n-i-2, MOD) * (n-i-1)
        else:
            tmp *= pow(2, n-i-1, MOD)
        tmp %= MOD
        ans += c[i] * tmp
    print(ans * pow(2, n, MOD) % MOD)

def __starting_point():
    main()
__starting_point()

def main():
    N = int(input())
    C = list(map(int, input().split()))
    C.sort()
    mod = 10 ** 9 + 7
    r = 0
    n = N
    i = 0
    for c in C:
        if n == 1:
            r = (r + c * pow(2, N - 1, mod)) % mod
        else:
            r = (r + c * (n + 1)* pow(2, n - 2, mod) * pow(2, N - n, mod)) % mod
        n -= 1
    return 2**N * r % mod

print((main()))


MOD = 1000000007

N = int(input())
C = list(map(int,input().split()))

C.sort(reverse=True)

ans = 0

if N > 1:
    for i in range(N):
        ans += C[i]*(2+i)*pow(2,N-2,MOD)*pow(2,N,MOD)
        ans %= MOD
else:
    ans = 2*C[0]%MOD

print(ans)

# coding: utf-8

import itertools
import sys

N = int(input())
C = [int(x) for x in input().split()]

# Cを昇順にソートしておく
C.sort()

# （C_iの個数×C_iのコスト）の総和×2**Nを求める
sum = 0
for i in range(N):
	sum += (N + 1 - i) * C[i]
sum *= 2 ** (N - 2)
sum *= 2 ** N

# 10**9 + 7で割った余りを求めて出力
print(int(sum % (10 ** 9 + 7)))

N=int(input());c=sorted(map(int,input().split()));m=10**9+7;print(sum([c[i]*(N-i+1)*pow(4,N-1,m) for i in range(N)])%m)

# 解説放送

def pow2(n, mod):
    """2のn乗まで"""
    t = 1
    yield t
    for _ in range(n):
        t = t * 2 % mod
        yield t


def main():
    MOD = 10 ** 9 + 7

    N = int(input())
    *c, = list(map(int, input().split()))

    c.sort()

    *two, = pow2(N, MOD)

    ans = 0
    for l, x in enumerate(c):
        # x:=係数.この位置の操作にかかるコストの総和を求める.
        # r:=xの右側にある要素数
        # (1<<r)個の状態を行として並べて,列で不一致数を確認すると,どの列も状態の半分が不一致.これがr列ある.
        r = N - l - 1

        t = two[r]
        if r != 0:
            t = (t + two[r - 1] * r) % MOD  # 右側の個数
        t = t * two[l] % MOD
        t = t * x % MOD
        ans = (ans + t) % MOD  # MOD忘れ

    ans = ans * two[N] % MOD
    print(ans)


def __starting_point():
    main()

__starting_point()

mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=0
if n==1:
  print((2*arr[0])%mod)
else:
  table=[1]
  for _ in range(n):
    tmp=table[-1]*2
    tmp%=mod
    table.append(tmp)
  for i in range(n):
    if i==n-1:    
      ans+=(table[i-1]*(n-i+1)*arr[i])%mod
    else:
      ans+=(table[i]*(n-i+1)*table[n-i-2]*arr[i])%mod
  print((ans*table[n])%mod)

import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


N = int(input())
C = list(map(int,input().split()))

# コストの小さいものから更新していけばいい
C.sort()

# 2のべき乗は先に計算しておく
beki = [1]
for i in range(1, 3*N+20):
    beki.append((beki[i-1]*2)%MOD)


ans = 0
for i in range(N):
    ans += (C[i] * beki[2*N-2] * (N-i+1))%MOD
    

print((ans % MOD))


MOD = 10**9+7

def solve(C):
    N = len(C)
    C.sort()

    dp1 = 0
    dp2 = 0
    for k,c in enumerate(C):
        ndp2 = 2*pow(4,k,MOD)*c + 4*dp2
        dp1 = 4*dp1 + ndp2 - 2*dp2
        dp2 = ndp2
        dp1 %= MOD
        dp2 %= MOD

    return dp1

def naive(C):
    from itertools import product
    N = len(C)
    C.sort()
    s = 0
    for a in product(range(2),repeat=N):
        for b in product(range(2),repeat=N):
            pop = 1
            for x,y,c in zip(a,b,reversed(C)):
                if x != y:
                    s += c*pop
                    pop += 1
    return s

def __starting_point():
    N = int(input())
    C = list(map(int,input().split()))
    print(solve(C))
__starting_point()

ans = 0
P = 10**9+7
n = int(input())
c = list(map(int, input().split()))
c = sorted(c)

for i in range(n):
    alr = pow(4, i, P)
    use_bit = n - 1 - i
    flip = pow(2, use_bit, P)
    ret = 1
    if use_bit > 0:
        ret = (pow(2, use_bit, P) + use_bit*pow(2, use_bit-1, P))%P
    ans = (ans + alr*flip*ret*c[i])%P

print(((ans*2)%P))


#E
n = int(input())
c = [int(i) for i in input().split()]
mod = 10**9+7

c.sort()
ans = 0
for i in range(n):
    ans += c[i]*(n-i+1)

ans %= mod
ans *= 4**(n-1)
ans %= mod
print(ans)

N=int(input())
c=sorted([int(i) for i in input().split()])
mod=10**9+7
ans=0
for i in range(N):
    ans+=(c[i]*(((N-i+1)*pow(2,(N-2)%(mod-1),mod))%mod))%mod
    ans%=mod
print((ans*pow(2,N,mod))%mod)


n = int(input())
cl = list(map(int, input().split()))
cl.sort(reverse=True)
MOD = 10**9+7

ans = 0
num = pow(2,n-1,MOD)
inc = pow(2,n-2,MOD)
for i in range(n):
    ans += num*cl[i]
    ans%=MOD
    num += inc
    num%=MOD

ans *= pow(2,n,MOD)
ans%=MOD
print(ans)

#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
C = LI()

MOD = 10 ** 9 + 7


def main():
    ans = 0
    C.sort()
    for i in range(N):
        x = C[i] * (N - i + 1) % MOD
        ans = (ans + x) % MOD
    ans = ans * pow(4, N - 1, MOD) % MOD
    print(ans)


def __starting_point():
    main()

__starting_point()

from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq
sys.setrecursionlimit(100000)

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
class mint:
    mod = int(1e9 + 7)
    def __init__(self, v = 0):
        if not ((v >= 0) and (v < mint.mod)):
            v %= mint.mod
            if v < 0: v += mint.mod
        self.V = v
    def __add__(self, other):
        v = self.V + (other.V if isinstance(other, mint) else other)
        return mint(v)
    def __sub__(self, other):
        v = self.V - (other.V if isinstance(other, mint) else other)
        return mint(v)
    def __mul__(self, other):
        v = self.V * (other.V if isinstance(other, mint) else other)
        return mint(v)
    def __floordiv__(self, other):
        v = self.V * mint.inv((other.V if isinstance(other, mint) else other))
        return mint(v)
    def __truediv__(self, other):
        v = self.V * mint.inv((other.V if isinstance(other, mint) else other))
        return mint(v)
    
    def __eq__(self, other):
        return self.V == (other.V if isinstance(other, mint) else mint(other).V)
    def __ne__(self, other):
        return self.V != (other.V if isinstance(other, mint) else other)
    def __int__(self): return self.V
    # right operand
    def __radd__(self, other):
        v = (other.V if isinstance(other, mint) else other) + self.V
        return mint(v)
    def __rsub__(self, other):
        v = (other.V if isinstance(other, mint) else other) - self.V
        return mint(v)
    def __rmul__(self, other):
        v = (other.V if isinstance(other, mint) else other) * self.V
        return mint(v)
    def __rfloordiv__(self, other):
        v = (other.V if isinstance(other, mint) else other) * mint.inv(self.V)
        return mint(v)
    def __rtruediv__(self, other):
        v = (other.V if isinstance(other, mint) else other) * mint.inv(self.V)
        return mint(v)

    @staticmethod
    def inv(x):
        a, _, _ = mint.extGCD(x, mint.mod)
        return (a + mint.mod) % mint.mod
    @staticmethod
    def extGCD(x, y):
        r0 = x
        r1 = y
        a0 = 1
        a1 = 0
        b0 = 0
        b1 = 1
        while(r1 > 0):
            q1 = r0 // r1
            r2 = r0 % r1
            a2 = a0 - q1 * a1
            b2 = b0 - q1 * b1
            r0 = r1; r1 = r2
            a0 = a1; a1 = a2
            b0 = b1; b1 = b2
        c = r0
        a = a0
        b = b0       
        return a, b, c
    @staticmethod
    def pow(x, k):
        x = x.V if isinstance(x, mint) else x
        return pow(x, k, mint.mod)

    
    def __str__(self):
        return str(self.V)
    def __repr__(self):
        return str(self.V)

def main():
    N = ri()
    A = ria()
    A = sorted(A)
    A = list(reversed(A))
    Pow2 = [mint(0)] * (N + 1)
    Pow2[0] = mint(1)
    for i in range(1,N+1): Pow2[i] = Pow2[i-1] * 2

    tot = mint(0)
    for i in range(N):
        tot += mint(A[i]) * Pow2[N-1]
        if i > 0: tot += mint(A[i]) * i * Pow2[N-2]
    tot *= Pow2[N]
    print(tot)

def __starting_point():
    main()

__starting_point()

n = int(input())
c = sorted(list(map(int, input().split())),reverse=True)
mod = 10**9 + 7
ans = 0
two = [1]
for i in range(n*2):
  two += [(two[i]*2) % mod]

for i in range(n):
  ans += (i+2) * c[i]
  ans %= mod
ans *= two[2*n - 2]
print(ans%mod)

n = int(input())
c = [int(i) for i in input().split()]
f = 0
c.sort()
c.reverse()
for i in range(n):
    f = f + c[i]*(i+2)
print(f*(4**(n-1))%(10**9+7))

N = int(input())
C = sorted(list(map(int,input().split())),reverse=True)
L = 10**9 + 7


if N > 1:
    b = 2**(N-2) % (L)
    a = [C[i] * b * (2+i) % L for i in range(N)]
    print(sum(a)*b*2*2%L)
else:
    print(C[0]*2%L)

def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


N = int(input())
C = list(map(int, input().split()))
C.sort()
MOD = 10**9 + 7

ans = 0
for i, c in enumerate(C, 1):
  ans = (ans + (N-i+2) * c) % MOD

ans *= power(4, N-1)
ans %= MOD
print(ans)

MOD = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort()

if N == 1:
    print (2 * C[0] % MOD)
    return


lst = [0] * (N + 3)
lst[0] = 1
for i in range(1, N + 3):
    lst[i] = (lst[i - 1] * 2) % MOD


ANS = 0
for i, c in enumerate(C):
    ANS += c * (N + 1 - i)

ANS *= pow(2, N - 2, MOD)
ANS %= MOD
ANS *= pow(2, N, MOD)
print (ANS % MOD)

MOD = 10 ** 9 + 7
N = int(input())
C = list(sorted(map(int, input().split()), reverse=True))

ans = 0
pow_list = [1] * (N + 1)
for i in range(1, N + 1):
    pow_list[i] = (2 * pow_list[i - 1]) % MOD
base = pow_list[N]

# 基本戦略:コストが一番高いものを一番最後に変更する
for i, c in enumerate(C):
    now = pow_list[N - i - 1]
    tot = 0
    # コストがi番目に大きい値は、最後からi番目に変更を行うので
    # 左からi-bitまでに何個1が立ったかで加算回数が決まる
    if i >= 1:
        tot = pow_list[i] + i * pow_list[i - 1]
    else:
        tot = pow_list[i]
    ans += (tot * now * c) % MOD
    ans %= MOD
print(ans * base % MOD)

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# テスト用コード
# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
# N-2がマイナスになる時に注意、一番右は2**(N-1)
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() % MOD * pow(2, N, MOD)
print((answer%MOD))


import numpy as np
MOD = 10**9 + 7

def plu(a,b):
    return (a + b)%MOD

plus = np.frompyfunc(plu,2,1)

n = int(input())
c = np.sort(np.array(input().split(),dtype = np.int64))
p = pow(2,2*n-2,MOD)
print((plus.reduce(np.mod(np.mod(p*c,MOD)*(n-np.arange(n)+1),MOD))))



N=int(input());c=sorted(list(map(int,input().split())));m=10**9+7;ans=0
for i in range(N):ans+=c[i]*(N-i+1)*pow(2,2*N-2,m)
print(ans%m)

import sys
import itertools
import fractions
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: list(map(int, stdin.readline().split()))
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
C=nl()
mod=10**9+7
n=0
C.sort()
two=[0]*(N+1)
two[0]=1
for i in range(N):
    two[i+1]=(two[i]*2)%mod
ans=0
for i in range(N):
    l=i
    r=N-1-i
    now=two[r]
    if(r!=0):
        now+=two[r-1]*r
    now*=two[i]
    now*=C[i]
    ans+=now
    ans%=mod

ans*=two[N]
print((ans%mod))
    


mod = 10**9 + 7
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)

b = pow(2, 2*n-2, mod)
a = 2 * b % mod

ans = 0
for i in range(n):
    ans += c[i] * (a + i * b)
    ans %= mod

print(ans)

n=int(input())
c=sorted(list(map(int,input().split())),reverse=True)
ans=0
mod=10**9+7
for i in range(1,n+1):
  ans+=c[i-1]*(i+1)%mod
print(4**(n-1)*ans%mod)