Buggy python submission (verdict: Runtime Error):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

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

arr = np.full(N + 1, 2 ** (N - 2))
arr = arr.cumsum()[1:]
arr %= MOD
# print(arr)
ans = arr * np.msort(C)[::-1]
print(int(ans.sum() * pow(2, N, MOD)) % MOD)




Fixed submission:
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)