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