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