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: MEDIUM

Solutions:
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)


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())
a = sorted([int(j) for j in input().split()])[::-1]
mod = 10 ** 9 + 7
ans = 0
for i in range(n):
	p = pow(4, n - 1, mod) * (i + 2) % mod
	ans = (ans + p * a[i]) % mod
print(ans)


mod = 10 ** 9 + 7
n = int(input())
c = [int(x) for x in input().split()]
c = sorted(c)
ans = 0
pow2 = [1]
for i in range(n + 1):
	tmp = pow2[-1] * 2 % mod
	pow2.append(tmp)
for i in range(n):
	ans += pow2[n] * pow2[i] * ((n - 1 - i) * pow2[n - 2 - i] + pow2[n - 1 - i]) * c[i]
	ans %= mod
print(ans)


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 = int(input())
C = list(map(int, input().split()))
MOD = 10 ** 9 + 7
fac = [1] * (N + 1)
for i in range(1, N + 1):
	fac[i] = fac[i - 1] * 2 % MOD
C.sort()
ans = 0
for (i, c) in enumerate(C):
	l = i
	r = N - l - 1
	tmp = fac[r] % MOD
	tmp += r * fac[r - 1] % MOD if r > 0 else 0
	tmp *= c * fac[l] % MOD
	ans += tmp % MOD
ans *= fac[N]
ans %= MOD
print(ans)


import sys
read = sys.stdin.buffer.read
mod = 10 ** 9 + 7
(n, *clst) = map(int, read().split())
clst.sort()
res = sum(((n + 2 - i) * item for (i, item) in enumerate(clst, 1)))
print(4 ** (n - 1) * res % mod)


N = int(input())
C = list(map(int, input().split()))
M = 10 ** 9 + 7
C.sort(reverse=True)
ans = 0
tmp = 0
for i in range(N):
	if i == 0:
		t = tmp + pow(2, 2 * N - 1, M)
	else:
		t = tmp + pow(2, 2 * N - 2, M)
	ans += t * C[i]
	tmp = t
print(ans % M)


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


N = int(input())
C = list(map(int, input().split()))
mod = 10 ** 9 + 7
C = sorted(C)[::-1]
ans = 0
for n in range(N):
	ans += pow(4, N - 1, mod) * (n + 2) * C[n]
	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()))
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)


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)


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


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())


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)
	exit()
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 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 = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
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)
print(ans % MOD)


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)


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)


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


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


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)


import sys
sys.setrecursionlimit(10 ** 6)
readline = sys.stdin.readline
read = sys.stdin.read
(n, *c) = [int(i) for i in read().split()]
c.sort(reverse=True)
MOD = 10 ** 9 + 7
ans = 0
for (i, ci) in enumerate(c):
	ans += (i + 2) * ci % MOD
	ans %= MOD
print(ans * pow(2, 2 * n - 2, MOD) % MOD)


import sys
input = sys.stdin.readline
N = int(input())
C = list(map(int, input().split()))
ans = 0
MOD = 10 ** 9 + 7
C.sort()
for i in range(N):
	left = pow(2, 2 * i, MOD)
	if i == N - 1:
		right = 1
	else:
		right = pow(2, 2 * N - 2 * i - 3, MOD) * (N - i + 1)
	ans += left * right * 2 * C[i]
	ans %= MOD
print(ans)


N = int(input())
(*C,) = map(int, input().split())
C.sort(reverse=True)
mod = 10 ** 9 + 7
ans = 0
for (i, c) in enumerate(C, start=1):
	ans += c * (i + 1)
ans *= 4 ** (N - 1)
ans %= mod
print(ans)


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


n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
	ans = (ans + (i + 2) * A[i]) % mod
for i in range(n * 2 - 2):
	ans = ans * 2 % 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 = [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)


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()


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)


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())


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)


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)


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


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


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


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)


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	N = int(input())
	C = list(reversed(sorted(getlist())))
	ans = 0
	for i in range(N):
		ans += pow(2, 2 * N - 2, con) * (i + 2) * C[i]
		ans %= con
	print(ans)
main()


MOD = 10 ** 9 + 7
MAXN = 4 * 10 ** 5
two_power = [1 for _ in range(MAXN + 10)]
for i in range(1, MAXN + 10):
	two_power[i] = two_power[i - 1] * 2 % MOD
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
ans = 0
x = two_power[2 * n - 1]
d = two_power[2 * n - 2]
for i in range(n):
	ans += (x + i * d) * c[i]
print(ans % MOD)


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)


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()


N = int(input())
C = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
C.sort()
ret = 0
for i in range(N):
	rest = N - i - 1
	if rest == 0:
		ret += C[i] * pow(4, i, mod) * pow(2, N - i, mod) * pow(2, rest, mod) % mod
	else:
		ret += C[i] * pow(4, i, mod) * pow(2, N - i, mod) * (rest + 2) * pow(2, rest - 1, mod) % mod
	ret %= mod
print(ret)


N = int(input())
C = list(map(int, input().split()))
MOD = 10 ** 9 + 7
C.sort()
C = C[::-1]
a0 = pow(2, N - 1, MOD)
d = pow(2, N - 2, MOD) if N - 2 >= 0 else 0
answer = 0
for i in range(N):
	answer = (answer + (a0 + d * i) * C[i]) % MOD
answer = answer * pow(2, N, MOD) % MOD
print(int(answer))


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

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(1000000000.0 + 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

	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()


from bisect import bisect_left
n = int(input())
c = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
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):
	b = bisect_left(c, c[i])
	x = n - i - 1
	ans += (p[x] + x * p[x - 1]) * c[i] * p[i]
	ans %= mod
print(ans * p[n] % mod)


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


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)


N = int(input())
(*C,) = map(int, input().split())
mod = 10 ** 9 + 7
C.sort()
ans = 0
for (i, c) in enumerate(C):
	tmp = (pow(2, N - 1 - i, mod) + pow(2, max(0, N - 2 - i), mod) * (N - 1 - i)) % mod
	tmp = tmp * c % mod
	tmp = tmp * pow(2, i, mod) % mod
	ans += tmp
	ans %= mod
ans *= pow(2, N, mod)
ans %= 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,) = 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())
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)


import sys
INF = 1000000000.0
mod = 1000000000.0 + 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)


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


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
(N, *C) = map(int, open(0).read().split())
C.sort(reverse=True)
print(pow(4, N - 1, mod) * sum((i * c for (i, c) in enumerate(C, 2))) % mod)


import sys
input = sys.stdin.buffer.readline
MOD = 10 ** 9 + 7
N = int(input())
Cs = sorted(map(int, input().split()), reverse=True)
magic = [pow(2, N - 1, MOD)]
for _ in range(N - 1):
	magic.append((magic[-1] + pow(2, N - 2, MOD)) % MOD)
ans = 0
for (C, m) in zip(Cs, magic):
	ans += C * m
	ans %= MOD
ans *= pow(2, N, MOD)
ans %= MOD
print(ans)


MOD = 10 ** 9 + 7
n = int(input())
c = sorted(list(map(int, input().split())), reverse=True)
print(pow(4, n - 1, MOD) * sum([(i + 2) * x for (i, x) in enumerate(c)]) % MOD)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)
A = [1]
for _ in range(N):
	A.append(A[-1] * 2 % mod)
t = C[0] * A[N - 1] % mod
for k in range(1, N):
	t = (t + C[k] * (A[N - 1] + k * A[N - 2]) % mod) % mod
print(t * A[N] % mod)


def e_change_a_little_bit(MOD=10 ** 9 + 7):
	N = int(input())
	C = [int(i) for i in input().split()]
	C.sort(reverse=True)
	ans = 0
	for i in range(N):
		ans += C[i] * (i + 1 + 1)
	ans *= 4 ** (N - 1)
	return ans % MOD
print(e_change_a_little_bit())


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 0
mod = 10 ** 9 + 7
for (i, ai) in enumerate(a):
	chk = pow(2, n - 1 - i, mod) + (n - 1 - i) * pow(2, max(0, n - 2 - i), mod)
	chk %= mod
	ans += chk * pow(2, i, mod) * ai
	ans %= mod
print(ans * pow(2, n, mod) % mod)


N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)
MOD = 10 ** 9 + 7
print(pow(4, N - 1, MOD) * sum((i * c for (i, c) in enumerate(C, 2))) % 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())
c = sorted([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
for k in range(N):
	a1 = pow(2, (N - 2) % (mod - 1), mod)
	a2 = N - k + 1
	tmp = a1 * a2 % mod
	ans += c[k] * tmp % mod
	ans %= mod
ans = ans * pow(2, N, mod)
ans %= mod
print(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)


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)


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


N = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
mod = 10 ** 9 + 7
tmp = 2 ** (N - 1) % mod
d = 2 ** (N - 2) % mod
ans = 0
for ci in c:
	ans += ci * tmp % mod
	ans %= mod
	tmp = (tmp + d) % mod
print(ans * 2 ** N % mod)


MOD = 10 ** 9 + 7
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)
mod4 = [0] * (N + 1)
mod4[0] = 1
for i in range(N):
	mod4[i + 1] = mod4[i] * 4 % MOD
ans = 0
N4 = mod4[N - 1]
for (i, c) in enumerate(C):
	j = i + 1
	ans += N4 * (j + 1) * c
	ans %= MOD
print(ans)


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


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()


N = int(input())
C = list(map(int, input().split()))
MOD = 10 ** 9 + 7
C.sort()
ans = 0
for i in range(N):
	l = i
	r = N - i - 1
	now = pow(2, r, MOD)
	if r > 0:
		now += pow(2, r - 1, MOD) * r
	now *= pow(2, l, MOD)
	now *= C[i]
	ans += now
print(ans * pow(2, N, MOD) % MOD)


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)


N = int(input())
C = sorted(list(map(int, input().split())), reverse=True)
ans = 0
mod = 10 ** 9 + 7
for (r, c) in enumerate(C):
	ans += c * (r + 2)
ans = ans * 2 ** (2 * N - 2) % 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)


n = int(input())
l = list(map(int, input().split()))
mod = 10 ** 9 + 7
tot = 0
l.sort(reverse=True)
for (i, x) in enumerate(l, 2):
	tot += x * i
	tot %= mod
print(tot * pow(2, n * 2 - 2, mod) % mod)


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)


import sys
sys.setrecursionlimit(10000000)
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10 ** 9 + 7
N = int(input())
C = [int(x) for x in input().split()]
C.sort(reverse=1)
x = 0
for (i, c) in enumerate(C, 1):
	x += c * (i + 1)
	x %= mod
print(x * pow(4, N - 1, mod) % 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)


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)


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


n = int(input())
clist = list(map(int, input().split()))
clist = sorted(clist)
answer = 0
kihon = 2 ** (n - 1) % (10 ** 9 + 7)
tas = 2 ** (n - 2) % (10 ** 9 + 7)
for i in range(n):
	answer += clist[-i - 1] * kihon
	answer = answer % (10 ** 9 + 7)
	kihon += tas
answer = answer * 2 ** n % (10 ** 9 + 7)
print(answer)


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)
main()


def pow2(n, mod):
	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):
		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()


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()


import sys
INF = float('inf')
MOD = 1000000007

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))
	C = [int(next(tokens)) for _ in range(N)]
	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()


M = 1000000007
N = int(input())
C = sorted(map(int, input().split()), reverse=True)

def pow(x, p):
	if p == 0:
		return 1
	if p % 2:
		a = pow(x, p - 1) % M
		return x * a % M
	else:
		a = pow(x, p // 2) % M
		return a * a % M
ans = 0
p2 = pow(2, 2 * N - 2) % M
for k in range(N):
	ans = (ans + C[k] * (p2 * k % M + 2 * p2) % M) % M
print(ans)


import sys

def solve():
	input = sys.stdin.readline
	N = int(input())
	C = [int(c) for c in input().split()]
	C.sort()
	mod = 7 + 10 ** 9
	SumC = 0
	for i in range(N):
		SumC += C[i] * (N - i + 1) % mod
		SumC %= mod
	SumC *= pow(4, N - 1, mod)
	SumC %= mod
	print(SumC)
	return 0
solve()


n = int(input())
c = list(map(int, input().split()))
MOD = 10 ** 9 + 7
c = sorted(c)
nokori = n - 1
ans = 0
ptn = pow(2, n, MOD) ** 2 * pow(2, MOD - 2, MOD) % MOD
for (i, val) in enumerate(c):
	ans += ptn * val + ptn * nokori * val * pow(2, MOD - 2, MOD)
	ans %= MOD
	nokori -= 1
print(ans % MOD)


N = int(input())
C = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
ANS = 0
for i in range(1, N + 1):
	ANS = ANS + C[-i] * (i + 1) * pow(2, N * 2 - 2, mod)
	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 = 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)


import itertools
import sys
N = int(input())
C = [int(x) for x in input().split()]
C.sort()
sum = 0
for i in range(N):
	sum += (N + 1 - i) * C[i]
sum *= 2 ** (N - 2)
sum *= 2 ** N
print(int(sum % (10 ** 9 + 7)))


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]
	m = m * p2[N + i] % MOD
	ans += m
print(ans % MOD)


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
N = I()
C = LI()
mod = 10 ** 9 + 7
C = [0] + sorted(C, reverse=True)
ans = 0
for i in range(1, N + 1):
	ans += C[i] * (i + 1)
	ans %= mod
ans *= pow(4, N - 1, mod)
ans %= mod
print(ans)


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)


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


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] * (n - i + 1) % mod
print(ans * 4 ** (n - 1) % mod)


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)


N = int(input())
C = sorted(map(int, input().split()), reverse=1)
m = 10 ** 9 + 7
x = pow(2, N - 1, m)
r = 0
for i in range(N):
	r += C[i] * x % m
	if N > 1:
		x += pow(2, N - 2, m)
print(pow(2, N, m) * r % m)


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


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


import sys
read = sys.stdin.buffer.read
mod = 10 ** 9 + 7
(n, *clst) = map(int, read().split())
if n == 1:
	print(clst[0] * 2 % mod)
	quit()
clst.sort(reverse=True)
res = sum((i * item for (i, item) in enumerate(clst, 2)))
print(4 ** (n - 1) * res % mod)


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)


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)


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


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] * (2 + (n - (i + 1))) * pow(4, n - 1, MOD)
	ans %= MOD
print(ans)


n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=1)
m = 10 ** 9 + 7
d = 2 ** (n - 2) % m
ans = 0
k = 2
for x in c:
	x = int(x % m)
	ans += x * k * d % m
	k += 1
ans = int(ans) % m * d * 4 % m
print(int(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 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))
pow2 = [1]
for k in range(1, N + 1):
	pow2.append(pow2[-1] * 2 % mod)
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)


import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)
MOD = int(1000000000.0 + 7)
PI = 3.141592653589793
INF = 1e+18
N = int(input())
C = list(map(int, input().split()))
C.sort()
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
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
cnt = 0
(a, b) = (pow(2, n - 1, MOD), 0 if n <= 1 else pow(2, n - 2, MOD))
for (i, x) in enumerate(c):
	cnt += (a + b * i) * x
	cnt %= MOD
print(cnt * pow(2, n, MOD) % MOD)


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


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


n = int(input())
C = list(map(int, input().split()))
mod = 10 ** 9 + 7
if n == 1:
	ans = 2 * C[0]
	ans %= mod
	print(ans)
	exit()
ans = 0
pattern = 2 ** (n - 1) % mod
d = 2 ** (n - 2) % mod
C.sort(reverse=True)
for c in C:
	ans += c * pattern % mod
	pattern += d
	pattern %= mod
	ans %= mod
print(ans * 2 ** n % mod)


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)


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


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)


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


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


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):
		(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()


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 main():
	MOD = 10 ** 9 + 7
	N = int(input())
	C = list(map(int, input().split(' ')))
	C.sort()
	pow_2 = 1
	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)
main()


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


LI = lambda : list(map(int, input().split()))
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)
main()


import sys
input = sys.stdin.readline
n = int(input())
c = list(map(int, input().split()))
INF = 10 ** 9 + 7
c.sort()
ans = 0
for i in range(n):
	ans = ans + c[i] * (n - i + 1)
	ans = ans % INF
x = pow(2, 2 * n - 2, INF)
ans = ans * x % INF
print(ans)


import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
N = int(readline())
C = list(map(int, readline().split()))
C.sort()
ans = 0
for i in range(N):
	ans = (ans + pow(2, 2 * N - 2, MOD) * C[i] * (N - i + 1)) % MOD
print(ans)


N = int(input())
C = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
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)


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)))


import sys
sys.setrecursionlimit(300000)
MOD = 1000000007

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))
	C = [int(next(tokens)) for _ in range(N)]
	solve(N, C)

def __starting_point():
	main()
__starting_point()


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))


N = int(input())
C = list(sorted(map(int, input().split())))
mod = int(1000000000.0 + 7)
f = [1] * (N + 1)
for i in range(1, N + 1):
	f[i] = f[i - 1] * 2 % mod
ans = 0
for i in range(N):
	(l, r) = (i, N - i - 1)
	res = f[r]
	if r > 0:
		res += f[r - 1] * r
	res = res * f[l] % mod
	res = res * C[i] % mod
	res = res * f[N] % mod
	ans = (ans + res) % mod
print(ans)


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


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)


n = int(input())
c = [int(i) for i in input().split()]
c.sort(reverse=True)
ans = 0
mod = 10 ** 9 + 7
no = n
for (i, j) in enumerate(c):
	if i == 0:
		ans += j * pow(2, no, mod)
	else:
		ans += j * (pow(2, i, mod) + pow(2, i - 1, mod) * i) * pow(2, no, mod)
	no -= 1
	ans %= mod
print(ans * pow(2, i, mod) % mod)


n = int(input())
c = sorted(list(map(int, input().split())))
mod = pow(10, 9) + 7
ans = 0
for (i, ci) in enumerate(c):
	l = i
	r = n - i
	b = pow(2, r - 1, mod) + (r - 1) * pow(2, r - 2, mod) if r > 1 else 1
	b *= pow(2, l, mod)
	ans += ci * b
	ans %= mod
ans *= pow(2, n, mod)
print(ans % mod)


N = int(input())
mod = int(1000000000.0) + 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)


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
	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()


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)


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


n = int(input())
p = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
p.sort()
ans = 0
for (i, c) in enumerate(p):
	mult = (pow(2, n - 1 - i, mod) + (n - 1 - i) * pow(2, n - 2 - i, mod)) % mod if i + 1 != len(p) else 1
	ans = (ans + pow(2, i, mod) * c % mod * mult) % mod
ans = ans * pow(2, n, mod) % mod
print(ans)


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)


N = int(input())
C = sorted(list(map(int, input().split())))
P = int(1000000000.0 + 7)
ans = 0
inv2 = pow(2, P - 2, P)
powa = inv2
powb = pow(2, N - 1, P)
for (i, c) in enumerate(C):
	powa = 2 * powa % P
	powb = inv2 * powb % P
	if i == N - 1:
		ans = (ans + powa * c) % P
	else:
		ans = (ans + powa * powb * (N - i + 1) * c) % P
print(ans * pow(2, N) % P)


mod = int(1000000000.0 + 7)
maxN = int(200000.0 + 100)
pow = [1] * maxN
cost = []

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)
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]))


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 += (i + 2) * C[i]
	ans %= mod
ans *= pow(2, 2 * N - 2, mod)
print(ans % mod)


n = int(input())
c = sorted(list(map(int, input().split())))[::-1]
M = int(1000000000.0 + 7)
power = [1]
for i in range(200005):
	power.append(2 * power[i] % M)
ans = 0
for i in range(n):
	ans += 2 * power[i] * (i * power[i - 1] + power[i]) * c[i] * power[n - i - 1] ** 2 % M
	ans %= M
print(ans)


(n, *c) = map(int, open(0).read().split())
mod = 10 ** 9 + 7
c.sort(reverse=True)
ans = 0
for (i, x) in enumerate(c):
	ans += x * (i + 2) % mod
	ans %= mod
print(ans * pow(4, n - 1) % mod)


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


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


import sys, bisect
input = sys.stdin.readline
n = int(input())
c = list(map(int, input().split()))
c.sort()
mod = 10 ** 9 + 7
se = pow(2, mod - 2, mod)
res = 0
for (i, e) in enumerate(c):
	cnt = pow(4, n, mod) % mod * se % mod
	res = (res + e * cnt) % mod
	res = (res + e * pow(4, n - 1, mod) % mod * (n - 1 - i) % mod) % mod
print(res % mod)


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


N = int(input())
A = sorted([int(a) for a in input().split()])[::-1]
P = 10 ** 9 + 7
print(sum([(i + 2) * A[i] for i in range(N)]) * pow(4, N - 1, P) % P)


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(reverse=True)
MOD = 10 ** 9 + 7
ans = 0
for (i, c) in enumerate(C, 1):
	ans += c * (i + 1) % MOD
ans *= power(4, N - 1)
ans %= MOD
print(ans)


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


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)


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)


N = int(input())
C = list(map(int, input().split()))
MOD = 1000000007
B = [0 for _ in range(N + 1)]
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)


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())
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())
if N == 1:
	C = int(input())
	print(2 * C % MOD)
	exit()
C = list(map(int, input().split()))
C.sort(reverse=True)
out = 0
tmp1 = pow(2, N - 1, MOD)
tmp2 = pow(2, N - 2, MOD)
for i in range(N):
	out += (tmp1 + tmp2 * i) * C[i]
	out %= MOD
out = out * pow(2, N, MOD)
print(int(out % 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

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()


import collections as c
ip = lambda : map(int, input().split())
mod = 10 ** 9 + 7
N = int(input())
l = list(ip())
l.sort()
ans = 0
f = 1
for i in range(N):
	ans = (ans + l[i] * (1 + N - i) % mod) % mod
	if i > 0:
		f = f * 4 % mod
ans = ans * f % mod
print(ans)


MOD = 1000000007

def modpow(a, p):
	res = 1
	while p > 0:
		if p % 2 == 1:
			res = res * a % MOD
		p = p // 2
		a = a * a % MOD
	return res
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
ans = 0
for (i, v) in enumerate(a):
	ans += modpow(2, 2 * n - i - 1) * v * (modpow(2, i) + i * modpow(2, i - 1))
	ans = 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]
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)


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


MOD = 10 ** 9 + 7
n = int(input())
c = list(map(int, input().split()))
c.sort()
if n > 1:
	ans = 0
	x = (1 << n - 1) % MOD
	y = (1 << n - 2) % MOD
	for i in range(n):
		m = x + y * (n - 1 - i) % MOD
		m %= MOD
		ans += c[i] * m
		ans %= MOD
	for i in range(n):
		ans *= 2
		ans %= MOD
else:
	ans = c[0] * 2
	ans %= MOD
print(ans)


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


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

def mpow(x, n):
	num = 1
	while n > 0:
		if n & 1:
			num = num * x % mod
		x = x * x % mod
		n = n >> 1
	return num
count = 0
for (i, c) in enumerate(C, 2):
	count += c * i
	count %= mod
print(count * mpow(2, N - 1) * mpow(2, N - 1) % mod)


n = int(input())
ccc = list(map(int, input().split()))
ccc.sort()
MOD = 10 ** 9 + 7
ans = 0
others = pow(4, n - 1, MOD)
for (i, c) in enumerate(ccc):
	ans = (ans + others * c * (n - i + 1)) % MOD
print(ans)


def main():
	mod = 1000000007
	n = int(input())
	C = list(map(int, input().split()))
	C.sort(reverse=True)
	ans = 0
	for (i, c) in enumerate(C):
		ans += c * (i + 2)
		ans %= mod
	ans *= pow(4, n - 1, mod)
	ans %= mod
	print(ans)
main()


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)


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
	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)


(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)


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)