N = int(input()) A = list(map(int, input().split())) ans = 0 MOD = 998244353 B = [0] * N tmp = 1 for i in range(1,N): B[i] = tmp + B[i-1] B[i] %= MOD tmp *= 2 tmp %= MOD for i in range(N): ans += (B[N-1-i] - B[i]) * A[i] ans %= MOD print(ans)