def examA():

    K, X = LI()

    if K*500>=X:

        ans = "Yes"

    else:

        ans = "No"

    print(ans)

    return



def examB():

    N = I()

    S = SI()

    ans = 0

    for i in range(N-2):

        if S[i:i+3]=="ABC":

            ans +=1

    print(ans)

    return



def examC():

    N = I()

    P = LI()

    Q = LI()

    Cp = [i for i in itertools.permutations(P,N)]; Cp.sort()

    Cq = [i for i in itertools.permutations(Q, N)]; Cq.sort()

#    print(Cp)

#    print(Cq)

    for k,i in enumerate(Cp):

        flag = True

        for j in range(N):

            if P[j]!=i[j]:

                flag = False

                break

        if flag:

            a = k

            break

    for k,i in enumerate(Cq):

        flag = True

        for j in range(N):

            if Q[j]!=i[j]:

                flag = False

                break

        if flag:

            b = k

            break

    ans = abs(a-b)

    print(ans)

    return



def gcd(x,y):

    if y==0:

        return x

    while(y!=0):

        x, y = y,x%y

    return x

def lcm(x, y):

    return x * y // gcd(x, y)

def examD():

    N, M = LI()

    A = LI()

    flag = 0

    for i in range(1,32):

        if A[0]%(2**i)==0:

            flag +=1

        else:

            break

#    print(flag)

    for a in A:

        cur = 0

        for i in range(1, 32):

            if a % (2 ** i) == 0:

                cur += 1

            else:

                break

        if cur!=flag:

            print((0))

            return

    cur = A[0]

    for i in range(1,N):

        cur = lcm(cur,A[i])

        if cur>2*M:

            print((0))

            return

    ans = 1 + (M-cur//2)//cur

    print(ans)

    return



def examE():

    N = I()

    C = LI(); C.sort(reverse = True)

    sumC = sum(C)

    sumC %=mod

    Cp = pow(2,N*2-2,mod)

    cur = (sumC*Cp*2) %mod

#    print(cur)

    for i in range(1,N):

        now = (Cp*C[i]*(i)) %mod

        cur +=now

        cur %=mod

    ans = cur

    print(ans)

    return



import sys,copy,bisect,itertools,heapq,math

from heapq import heappop,heappush,heapify

from collections import Counter,defaultdict,deque

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

def LI(): return list(map(int,sys.stdin.readline().split()))

def LSI(): return list(map(str,sys.stdin.readline().split()))

def LS(): return sys.stdin.readline().split()

def SI(): return sys.stdin.readline().strip()

global mod,mod2,inf,alphabet

mod = 10**9 + 7

mod2 = 998244353

inf = 10**18

alphabet = [chr(ord('a') + i) for i in range(26)]



if __name__ == '__main__':

    examE()

def examA():

    N = I()

    X = [LI()for _ in range(N)]

    l = 0; r = inf

    while(r-l>_ep):

        now = (l+r)/2

        x_l = -inf; x_r = inf

        y_l = -inf; y_r = inf

        for x,y,c in X:

            move = now / c

            x_l = max(x_l,x-move)

            x_r = min(x_r,x+move)

            y_l = max(y_l,y-move)

            y_r = min(y_r,y+move)

        if x_l<=x_r-_ep and y_l<=y_r-_ep:

            r = now

        else:

            l = now

    ans = r

    print(ans)

    return



def examB():

    N = I()

    C = LI()

    C.sort()

    base = pow(2,2*N-1,mod)

    inv = pow(2,mod-2,mod)

    ans = 0

    for i in range(N):

        cur = C[i]*base*(1+(N-1-i)*inv)

        ans += cur

        ans %= mod

    print(ans)

    return



def examC():

    ans = 0

    print(ans)

    return





import sys,bisect,itertools,heapq,math,random

from copy import deepcopy

from heapq import heappop,heappush,heapify

from collections import Counter,defaultdict,deque

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

def I(): return int(readline())

def LI(): return list(map(int,readline().split()))

def LSI(): return list(map(str,sys.stdin.readline().split()))

def LS(): return sys.stdin.readline().split()

def SI(): return sys.stdin.readline().strip()

global mod,mod2,inf,alphabet,_ep

mod = 10**9 + 7

mod2 = 998244353

inf = 10**18

_ep = 10**(-9)

alphabet = [chr(ord('a') + i) for i in range(26)]



sys.setrecursionlimit(10**7)



if __name__ == '__main__':

    examB()



"""

142

12 9 1445 0 1

asd dfg hj o o

aidn

"""
def examA():
    K, X = LI()
    if K * 500 >= X:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return


def examB():
    N = I()
    S = SI()
    ans = 0
    for i in range(N - 2):
        if S[i : i + 3] == "ABC":
            ans += 1
    print(ans)
    return


def examC():
    N = I()
    P = LI()
    Q = LI()
    Cp = [i for i in itertools.permutations(P, N)]
    Cp.sort()
    Cq = [i for i in itertools.permutations(Q, N)]
    Cq.sort()
    #    print(Cp)
    #    print(Cq)
    for k, i in enumerate(Cp):
        flag = True
        for j in range(N):
            if P[j] != i[j]:
                flag = False
                break
        if flag:
            a = k
            break
    for k, i in enumerate(Cq):
        flag = True
        for j in range(N):
            if Q[j] != i[j]:
                flag = False
                break
        if flag:
            b = k
            break
    ans = abs(a - b)
    print(ans)
    return


def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


def examD():
    N, M = LI()
    A = LI()
    flag = 0
    for i in range(1, 32):
        if A[0] % (2**i) == 0:
            flag += 1
        else:
            break
    #    print(flag)
    for a in A:
        cur = 0
        for i in range(1, 32):
            if a % (2**i) == 0:
                cur += 1
            else:
                break
        if cur != flag:
            print((0))
            return
    cur = A[0]
    for i in range(1, N):
        cur = lcm(cur, A[i])
        if cur > 2 * M:
            print((0))
            return
    ans = 1 + (M - cur // 2) // cur
    print(ans)
    return


def examE():
    N = I()
    C = LI()
    C.sort(reverse=True)
    sumC = sum(C)
    sumC %= mod
    Cp = pow(2, N * 2 - 2, mod)
    cur = (sumC * Cp * 2) % mod
    #    print(cur)
    for i in range(1, N):
        now = (Cp * C[i] * (i)) % mod
        cur += now
        cur %= mod
    ans = cur
    print(ans)
    return


import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque


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


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LSI():
    return list(map(str, sys.stdin.readline().split()))


def LS():
    return sys.stdin.readline().split()


def SI():
    return sys.stdin.readline().strip()


global mod, mod2, inf, alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord("a") + i) for i in range(26)]
if __name__ == "__main__":
    examE()

def examA():
    N = I()
    X = [LI() for _ in range(N)]
    l = 0
    r = inf
    while r - l > _ep:
        now = (l + r) / 2
        x_l = -inf
        x_r = inf
        y_l = -inf
        y_r = inf
        for x, y, c in X:
            move = now / c
            x_l = max(x_l, x - move)
            x_r = min(x_r, x + move)
            y_l = max(y_l, y - move)
            y_r = min(y_r, y + move)
        if x_l <= x_r - _ep and y_l <= y_r - _ep:
            r = now
        else:
            l = now
    ans = r
    print(ans)
    return


def examB():
    N = I()
    C = LI()
    C.sort()
    base = pow(2, 2 * N - 1, mod)
    inv = pow(2, mod - 2, mod)
    ans = 0
    for i in range(N):
        cur = C[i] * base * (1 + (N - 1 - i) * inv)
        ans += cur
        ans %= mod
    print(ans)
    return


def examC():
    ans = 0
    print(ans)
    return


import sys, bisect, itertools, heapq, math, random
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque

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


def I():
    return int(readline())


def LI():
    return list(map(int, readline().split()))


def LSI():
    return list(map(str, sys.stdin.readline().split()))


def LS():
    return sys.stdin.readline().split()


def SI():
    return sys.stdin.readline().strip()


global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10 ** (-9)
alphabet = [chr(ord("a") + i) for i in range(26)]
sys.setrecursionlimit(10**7)
if __name__ == "__main__":
    examB()
"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

-    K, X = LI() -    if K * 500 >= X: -        ans = "Yes" -    else: -        ans = "No" +    N = I() +    X = [LI() for _ in range(N)] +    l = 0 +    r = inf +    while r - l > _ep: +        now = (l + r) / 2 +        x_l = -inf +        x_r = inf +        y_l = -inf +        y_r = inf +        for x, y, c in X: +            move = now / c +            x_l = max(x_l, x - move) +            x_r = min(x_r, x + move) +            y_l = max(y_l, y - move) +            y_r = min(y_r, y + move) +        if x_l <= x_r - _ep and y_l <= y_r - _ep: +            r = now +        else: +            l = now +    ans = r -    S = SI() +    C = LI() +    C.sort() +    base = pow(2, 2 * N - 1, mod) +    inv = pow(2, mod - 2, mod) -    for i in range(N - 2): -        if S[i : i + 3] == "ABC": -            ans += 1 +    for i in range(N): +        cur = C[i] * base * (1 + (N - 1 - i) * inv) +        ans += cur +        ans %= mod -    N = I() -    P = LI() -    Q = LI() -    Cp = [i for i in itertools.permutations(P, N)] -    Cp.sort() -    Cq = [i for i in itertools.permutations(Q, N)] -    Cq.sort() -    #    print(Cp) -    #    print(Cq) -    for k, i in enumerate(Cp): -        flag = True -        for j in range(N): -            if P[j] != i[j]: -                flag = False -                break -        if flag: -            a = k -            break -    for k, i in enumerate(Cq): -        flag = True -        for j in range(N): -            if Q[j] != i[j]: -                flag = False -                break -        if flag: -            b = k -            break -    ans = abs(a - b) +    ans = 0 -def gcd(x, y): -    if y == 0: -        return x -    while y != 0: -        x, y = y, x % y -    return x - - -def lcm(x, y): -    return x * y // gcd(x, y) - - -def examD(): -    N, M = LI() -    A = LI() -    flag = 0 -    for i in range(1, 32): -        if A[0] % (2**i) == 0: -            flag += 1 -        else: -            break -    #    print(flag) -    for a in A: -        cur = 0 -        for i in range(1, 32): -            if a % (2**i) == 0: -                cur += 1 -            else: -                break -        if cur != flag: -            print((0)) -            return -    cur = A[0] -    for i in range(1, N): -        cur = lcm(cur, A[i]) -        if cur > 2 * M: -            print((0)) -            return -    ans = 1 + (M - cur // 2) // cur -    print(ans) -    return - - -def examE(): -    N = I() -    C = LI() -    C.sort(reverse=True) -    sumC = sum(C) -    sumC %= mod -    Cp = pow(2, N * 2 - 2, mod) -    cur = (sumC * Cp * 2) % mod -    #    print(cur) -    for i in range(1, N): -        now = (Cp * C[i] * (i)) % mod -        cur += now -        cur %= mod -    ans = cur -    print(ans) -    return - - -import sys, copy, bisect, itertools, heapq, math +import sys, bisect, itertools, heapq, math, random +from copy import deepcopy +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + -    return int(sys.stdin.readline()) +    return int(readline()) -    return list(map(int, sys.stdin.readline().split())) +    return list(map(int, readline().split())) -global mod, mod2, inf, alphabet +global mod, mod2, inf, alphabet, _ep +_ep = 10 ** (-9) +sys.setrecursionlimit(10**7) -    examE() +    examB() +""" +142 +12 9 1445 0 1 +asd dfg hj o o +aidn +"""