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