import os

import sys



import numpy as np



# from libs.debug import debug



if os.getenv("LOCAL"):

    sys.stdin = open("_in.txt", "r")



sys.setrecursionlimit(10 ** 9)

INF = float("inf")

IINF = 10 ** 18

MOD = 10 ** 9 + 7

# MOD = 998244353





N = int(sys.stdin.buffer.readline())

C = list(map(int, sys.stdin.buffer.readline().split()))

C.sort()



#

# @debug

# def f(S, T, C):

#     S = np.array(S, dtype=bool)

#     T = np.array(T, dtype=bool)

#     C = np.array(C, dtype=int)

#     costs = np.msort(C[S != T])

#     return int(np.dot(costs[::-1], np.arange(1, len(costs) + 1)))

#

#

# def test(N, C):

#     ans = 0

#     for s in itertools.product([True, False], repeat=N):

#         for t in itertools.product([True, False], repeat=N):

#             ans += f(s, t, C)

#             ans %= MOD

#     print(ans)

#

#

# test(N, C)



# R = np.zeros((N + 1, N), dtype=int)

# R[0] = 0

# R[1] = 1

# for r in range(2, N + 1):

#     for c in range(N):

#         R[r, c] = R[r - 1][:c].sum()

# print(R)

# print(R * np.arange(N + 1)[:, None])

# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))

# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1])

# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum())

# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum() * (2 ** N) % MOD)

#

# print()

# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))

# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0))

# print(np.diff((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0)))



if N == 1:

    arr = np.ones(1, dtype=int)

else:

    arr = np.full(N + 1, pow(2, N - 2, MOD), dtype=int)

    arr = arr.cumsum()[1:]

    arr %= MOD

# print(arr)

ans = arr * np.msort(C)[::-1] % MOD

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

# print(ans.sum() * pow(2, N, MOD) % MOD)

import os

import sys



import numpy as np



# from libs.debug import debug



if os.getenv("LOCAL"):

    sys.stdin = open("_in.txt", "r")



sys.setrecursionlimit(10 ** 9)

INF = float("inf")

IINF = 10 ** 18

MOD = 10 ** 9 + 7

# MOD = 998244353





N = int(sys.stdin.buffer.readline())

C = list(map(int, sys.stdin.buffer.readline().split()))



# @debug

# def f(S, T, C):

#     S = np.array(S, dtype=bool)

#     T = np.array(T, dtype=bool)

#     C = np.array(C, dtype=int)

#     costs = np.msort(C[S != T])

#     return int(np.dot(costs[::-1], np.arange(1, len(costs) + 1)))

#

#

# def test(N, C):

#     ans = 0

#     for s in itertools.product([True, False], repeat=N):

#         for t in itertools.product([True, False], repeat=N):

#             ans += f(s, t, C)

#             ans %= MOD

#     print(ans)

#

#

# test(N, C)



# R[d][i]: C が降順にソートされてるとして、C[i] が上から d 番目の大きさになる選び方の数

# R = np.zeros((N + 1, N), dtype=int)

# R[0] = 0

# R[1] = 1

# for r in range(2, N + 1):

#     for c in range(N):

#         R[r, c] = R[r - 1][:c].sum()

# # 自分より大きいのの選び方の総数

# print(R)

# # 順位かける

# print(R * np.arange(N + 1)[:, None])

# # 自分より小さいのの選び方をかける

# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))

# # 順位が小さいのに大きいのをかける

# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1])

# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum())

# # 同じ選び方が 2**N 個ある

# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum() * (2 ** N) % MOD)



# print()

# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))

# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0))

# print(np.diff((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0)))





if N == 1:

    arr = np.ones(1, dtype=int)

else:

    arr = np.arange(N, dtype=int) * pow(2, N - 2, MOD) + pow(2, N - 1, MOD)

ans = arr % MOD * np.msort(C)[::-1] % MOD

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

import os
import sys
import numpy as np

# from libs.debug import debug
if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
N = int(sys.stdin.buffer.readline())
C = list(map(int, sys.stdin.buffer.readline().split()))
C.sort()
#
# @debug
# def f(S, T, C):
#     S = np.array(S, dtype=bool)
#     T = np.array(T, dtype=bool)
#     C = np.array(C, dtype=int)
#     costs = np.msort(C[S != T])
#     return int(np.dot(costs[::-1], np.arange(1, len(costs) + 1)))
#
#
# def test(N, C):
#     ans = 0
#     for s in itertools.product([True, False], repeat=N):
#         for t in itertools.product([True, False], repeat=N):
#             ans += f(s, t, C)
#             ans %= MOD
#     print(ans)
#
#
# test(N, C)
# R = np.zeros((N + 1, N), dtype=int)
# R[0] = 0
# R[1] = 1
# for r in range(2, N + 1):
#     for c in range(N):
#         R[r, c] = R[r - 1][:c].sum()
# print(R)
# print(R * np.arange(N + 1)[:, None])
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1])
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum())
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum() * (2 ** N) % MOD)
#
# print()
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0))
# print(np.diff((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0)))
if N == 1:
    arr = np.ones(1, dtype=int)
else:
    arr = np.full(N + 1, pow(2, N - 2, MOD), dtype=int)
    arr = arr.cumsum()[1:]
    arr %= MOD
# print(arr)
ans = arr * np.msort(C)[::-1] % MOD
print((sum(ans) % MOD * pow(2, N, MOD) % MOD))
# print(ans.sum() * pow(2, N, MOD) % MOD)

import os
import sys
import numpy as np

# from libs.debug import debug
if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
N = int(sys.stdin.buffer.readline())
C = list(map(int, sys.stdin.buffer.readline().split()))
# @debug
# def f(S, T, C):
#     S = np.array(S, dtype=bool)
#     T = np.array(T, dtype=bool)
#     C = np.array(C, dtype=int)
#     costs = np.msort(C[S != T])
#     return int(np.dot(costs[::-1], np.arange(1, len(costs) + 1)))
#
#
# def test(N, C):
#     ans = 0
#     for s in itertools.product([True, False], repeat=N):
#         for t in itertools.product([True, False], repeat=N):
#             ans += f(s, t, C)
#             ans %= MOD
#     print(ans)
#
#
# test(N, C)
# R[d][i]: C が降順にソートされてるとして、C[i] が上から d 番目の大きさになる選び方の数
# R = np.zeros((N + 1, N), dtype=int)
# R[0] = 0
# R[1] = 1
# for r in range(2, N + 1):
#     for c in range(N):
#         R[r, c] = R[r - 1][:c].sum()
# # 自分より大きいのの選び方の総数
# print(R)
# # 順位かける
# print(R * np.arange(N + 1)[:, None])
# # 自分より小さいのの選び方をかける
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))
# # 順位が小さいのに大きいのをかける
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1])
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum())
# # 同じ選び方が 2**N 個ある
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]) * np.msort(C)[::-1]).sum() * (2 ** N) % MOD)
# print()
# print(R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1]))
# print((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0))
# print(np.diff((R * np.arange(N + 1)[:, None] * (2 ** np.arange(N)[::-1])).sum(axis=0)))
if N == 1:
    arr = np.ones(1, dtype=int)
else:
    arr = np.arange(N, dtype=int) * pow(2, N - 2, MOD) + pow(2, N - 1, MOD)
ans = arr % MOD * np.msort(C)[::-1] % MOD
print((sum(ans) % MOD * pow(2, N, MOD) % MOD))

-C.sort() -# +# R[d][i]: C が降順にソートされてるとして、C[i] が上から d 番目の大きさになる選び方の数 +# # 自分より大きいのの選び方の総数 +# # 順位かける +# # 自分より小さいのの選び方をかける +# # 順位が小さいのに大きいのをかける +# # 同じ選び方が 2**N 個ある -# -    arr = np.full(N + 1, pow(2, N - 2, MOD), dtype=int) -    arr = arr.cumsum()[1:] -    arr %= MOD -# print(arr) -ans = arr * np.msort(C)[::-1] % MOD +    arr = np.arange(N, dtype=int) * pow(2, N - 2, MOD) + pow(2, N - 1, MOD) +ans = arr % MOD * np.msort(C)[::-1] % MOD -# print(ans.sum() * pow(2, N, MOD) % MOD)