N=int(input()) A=list(map(int,input().split())) mod=998244353 print((pow(2,N-1,mod)*A[0]-sum(A))%mod)