import sys input = sys.stdin.readline from collections import * N = int(input()) A = list(map(int, input().split())) ans = 0 acc = 0 MOD = 998244353 p = [1] for i in range(N+10): p.append(p[-1]*2%MOD) for i in range(N): r = p[N-1-i] add = (acc-A[i]*(p[i]-1))*r%MOD ans += add ans %= MOD acc += p[i]*A[i] acc %= MOD print(ans)