N = int(input()) A = list(map(int,input().split())) mod = 998244353 n = len(set(A)) ans = 0 cumJ = 0 base = 1 powmat = [0] * (2 * N) powmat[0] = 1 for i in range(1,2*N): powmat[i] = powmat[i-1] * 2 powmat[i] %=mod for i in range(N): ans -=(cumJ * powmat[N-1-i])%mod * A[i] ans %=mod ''' ans += segJ.sum(0,zipped[i]) * pow(2,N-1-i) * A[i] ans %=mod ''' cumJ += base cumJ %=mod base *=2 base %=mod rev2 = pow(2,mod-2,mod) cumI = [0] * N cumI[0] = 1 for i in range(1,N): cumI[i] = cumI[i-1] * rev2 cumI[i] %=mod def acum(List):#累積和 rev = [0 for _ in range(len(List))] for i in range(len(List)): if i == 0: rev[i] = List[i] else: rev[i] = rev[i-1] + List[i] rev[i] %=mod return rev cumI = acum(cumI) for i in reversed(range(N)): ''' ans -= segI.sum(zipped[i]+1,n) * pow(2,N-1+i) * A[i] ans %=mod ''' ans += ((cumI[N-1]-cumI[i]) * powmat[N-1+i]) % mod * A[i] ans %=mod print(ans)