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