You are given two sequences, S and T, each of length N, consisting of 0s and 1s. The function f(S, T) calculates the minimum total cost to transform S into T. The cost of changing S_i (from 0 to 1 or vice versa) is D * C_i, where D is the number of indices j such that S_j ≠ T_j just before the change. You need to compute the sum of f(S, T) over all pairs of sequences (S, T) and output the result modulo (10^9+7). The input consists of N followed by N values of C_i. Output the sum of f(S, T) modulo (10^9+7).

# Buggy version:
MOD = 10**9+7

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

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

    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

if __name__ == '__main__':
    N = int(input())
    C = list(map(int,input().split()))
    print(solve(C))

# Fixed version:
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

if __name__ == '__main__':
    N = int(input())
    C = list(map(int,input().split()))
    print(solve(C))

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


pp = [None]*n
v = 1
for i in range(n):
    pp[i] = v
    v *= 2
    v %= M
    
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*(pp[i] + i*pp[i-1])*pp[n-i-1]
    ans %= M
ans *= pow(2,n,M)
ans %= M
print(ans)

# Fixed version:
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)

# Buggy version:
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, C):
    bp = [0]
    mod = 10**9 + 7
    for i in range(N+1):
        bp.append(bp[-1] + (1<<i))

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

    return ans % mod




def main():
    N = read_int()
    C = read_int_n()
    print(slv(N, C))


if __name__ == '__main__':
    main()


# Fixed version:
# -*- coding: utf-8 -*-
import queue
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, C):
    mod = 10**9 + 7
    if N == 1:
        return (C[0] * 2) % mod

    C.sort()
    ans = 0
    a = pow(2, N, mod)
    b = pow(2, N-1, mod)
    c = pow(2, N-2, mod)
    for i in range(N):
        d = (N-i-1) * c
        d %= mod
        n = a * (b + d)
        n %= mod
        ans += n * C[i]
        ans %= mod

    return ans % mod




def main():
    N = read_int()
    C = read_int_n()
    print(slv(N, C))


if __name__ == '__main__':
    main()

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


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)

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

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


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)

# Buggy version:
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
print(ans)


# Fixed version:
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)

# Buggy version:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
mod = 10 ** 9 + 7
res = 0
if N == 1:
  print(a[0] * 2)
  exit(0)
for i in range(N):
  res += a[i] * (pow(2, N - 1, mod) % mod + pow(2, N - 2, mod) * i % mod) % mod
  res %= mod
print(res * pow(2, N, mod) % mod)

# Fixed version:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
mod = 10 ** 9 + 7
res = 0
if N == 1:
  print(a[0] * 2 % mod)
  exit(0)
for i in range(N):
  res += a[i] * (pow(2, N - 1, mod) % mod + pow(2, N - 2, mod) * i % mod) % mod
  res %= mod
print(res * pow(2, N, mod) % mod)

# Buggy version:
n = int(input())
c = sorted(list(map(int, input().split())))
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)

# Fixed version:
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)

# Buggy version:
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]* 2**(N-2) * (N+1-ind)
    ans %= mod
print(ans*2**N %mod)

# Fixed version:
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)

# Buggy version:
n = int(input())
c = list(map(int, input().split()))
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)

# Fixed version:
n = int(input())
c = sorted(list(map(int, input().split())), reverse=True)
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)

# Buggy version:
# coding: utf-8

import itertools

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(sum % (10 ** 9 + 7))

# Fixed version:
# 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)))

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

# Fixed version:
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))

# Buggy version:
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
print(arr)
ans=0
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)

# Fixed version:
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)

# Buggy version:
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+1) * c[i]
  ans %= mod
ans *= two[2*n - 2]
print(ans%mod)

# Fixed version:
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)

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

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

# Buggy version:
import sys
input = sys.stdin.readline
n = int(input())
mod = 10**9+7
a = list(map(int,input().split()))
a.sort()
ans = 0
const = pow(2,n,mod)
if n == 1:
  print(a[0]*3)
  exit()
for i in range(n):
  ans = (ans + a[i]*const*(pow(2,n-1,mod)+pow(2,n-2,mod)*(n-i-1))%mod)%mod
print(ans)

# Fixed version:
import sys
input = sys.stdin.readline
n = int(input())
mod = 10**9+7
a = list(map(int,input().split()))
a.sort()
ans = 0
const = pow(2,n,mod)
if n == 1:
  print(a[0]*2%mod)
  exit()
for i in range(n):
  ans = (ans + a[i]*const*(pow(2,n-1,mod)+pow(2,n-2,mod)*(n-i-1))%mod)%mod
print(ans)

# Buggy version:
n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=True)
res=0
ans=0
mod=10**9+7
p=pow(2,n*2-2,mod)
for i in range(n):
   ans+=(c[i]*(i+2)%mod)*p
prit(ans)

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

# Buggy version:
N = int(input())
C = list(map(int, input().split()))

a = 10**9+7
C = list(reversed(sorted(C)))

count = 0
# Cに掛ける数
# N=1 1
# N=2 2, 3
# N=3 4, 6, 8
# N=4 8, 12, 16, 20
for i in range(0, N):
    count += C[i] * (2**(N-1) + 2**(N-2) * i)
    count %= a

print(count * 2**N % a)

# Fixed version:
N = int(input())
C = list(map(int, input().split()))

a = 10**9+7
C = list(reversed(sorted(C)))

count = 0
# Cに掛ける数
# N=1 1
# N=2 2, 3
# N=3 4, 6, 8
# N=4 8, 12, 16, 20
for i in range(0, N):
    count += C[i] * (2+i)

print(count * 4**(N-1) % a)

# Buggy version:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    c = LI()
    c.sort()
    if n == 1:
        print(2*c[0]%mod)
        return
    k = pow(2,n-2,mod)
    p = pow(2,n,mod)
    f = [k*(i+2)*p%mod for i in range(n)][::-1]
    ans = 0
    for i in range(n):
        ans += c[i]*f[i]
        ans %= mod
    print(ans*p%mod)
    return

#Solve
if __name__ == "__main__":
    solve()


# Fixed version:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    c = LI()
    c.sort(reverse = True)
    dp = [0]*n
    dp[0] = c[0]
    p = 1
    for i in range(n-1):
        ni = i+1
        dp[ni] = (2*dp[i]+p*(2+ni)*c[ni])%mod
        p *= 2
        p %= mod
    p *= 2
    p %= mod
    print(p*dp[n-1]%mod)
    return

#Solve
if __name__ == "__main__":
    solve()

# Buggy version:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n=int(input())
	c=list(map(int,input().split()))
	c.sort()
	c=c[::-1]
	
	ans=0
	a = (2 ** n) % mod
	
	for i in range(n):
		aa=c[i]%mod
		aaa=(2**(n-1))%mod+((i)*2**(n-2))%mod
		ans+=(a*aa*aaa)%mod
	print(ans)
	
	
	


if __name__ == "__main__":
	main()


# Fixed version:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n=int(input())
	c=list(map(int,input().split()))
	c.sort()
	c=c[::-1]
	
	ans=0
	nn=[1]
	for i in range(n+1):
		nn.append(nn[-1]*2%mod)
		
	a=nn[n]
	
	for i in range(n):
		aa=c[i]%mod
		aaa=nn[n-1]+((i)*nn[n-2])%mod
		ans+=(a*aa*aaa)
		ans%=mod
		
	print(int(ans))
	
	
	


if __name__ == "__main__":
	main()

# Buggy version:
import sys
n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10**9+7

res = 0
ls = [2**i % MOD for i in range(n)]
for i, c in enumerate(c_ls):
    res += (ls[n-2] * (i+2)) * c % MOD
    res %= MOD
res = res * (2**n) % MOD
print(int(res))

# Fixed version:
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))

# Buggy version:
n = int(input())
c = list(map(int, input().split()))

mod = 10**9 + 7
c.sort()
ans = 0

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

print(ans)

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

# Buggy version:
MOD = 10**9+7
N = int(input())
C = list(map(int,input().split()))
C.sort(reverse=True)
nu = pow(2,N-1,MOD)
owt = pow(2,MOD-2,MOD)
A = [nu]*N
hoge = 0
piyo = nu
for i in range(N):
    A[i] += hoge
    piyo = (piyo*owt)%MOD
    hoge = (hoge+piyo)%MOD
ans = 0
for i in range(N):
    ans = (ans + C[i]*A[i])%MOD
ans = (ans * pow(2,N,MOD))%MOD

print(ans)

# Fixed version:
MOD = 10**9+7
N = int(input())
C = list(map(int,input().split()))
C.sort(reverse=True)
nu = pow(2,N-1,MOD)
owt = pow(2,MOD-2,MOD)
A = [nu]*N
hoge = (nu*owt)%MOD
for i in range(1,N):
    A[i] = (A[i-1]+hoge)%MOD
ans = 0
for i in range(N):
    ans += A[i]*C[i]
    ans %= MOD
print((ans*pow(2,N,MOD))%MOD)

# Buggy version:
N = int(input())
C = list(map(int, input().split()))

C.sort()

ans = 0

for i in range(N):
    ans += C[i] * (N + 1 - i) * (2 ** (N - 2))
    ans %= 10 ** 9 + 7

print(ans * (2 ** N))

# Fixed version:

N = int(input())

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

C.sort()

ans = 0

mod = 10 ** 9 + 7
two = [1]

for i in range(N+10):
    two.append(two[-1] * 2 % mod)

for i in range(N):

    ans += C[i] * ((two[N-1] * two[N-1] * (N-1-i)) + two[N-1] * two[N] )
    ans %= mod

print (ans)

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


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

# Buggy version:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=10**9+7
    if n==1:
        print(2*a[0]%mod)
        return
    a.sort(key=lambda x:-x)
    mod=10**9+7
    ans=sum([a[i]*(i+2))%mod for i in range(n)])
    ans=ans*pow(2,n,mod)*pow(2,n-2,mod)%mod
    print(ans)

main()

# Fixed version:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=10**9+7
    if n==1:
        print(2*a[0]%mod)
        return
    a.sort(key=lambda x:-x)
    mod=10**9+7
    ans=0
    for i in range(n):
        ans=(ans+pow(2,n-2,mod)*a[i]*(i+2))%mod
    ans=ans*pow(2,n,mod)%mod
    print(ans)

main()

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


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