N = int(eval(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(eval(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(eval(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(eval(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)

+P = pow(4, N - 1, mod) -    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 += C[i] * P * (N - i + 1) % mod