import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() a = li() ans = 0 for i in range(n): ans += (pow(2, n - 1, mod) - pow(2, n - i - 1, mod)) * a[i] ans %= mod ans -= (pow(2, n - 1, mod) - pow(2, i, mod) * a[i]) ans %= mod print(ans)