#include using namespace std; #ifdef _RUTHEN #include #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; #include using mint = atcoder::modint998244353; void solve() { int N; cin >> N; V A(N); rep(i, N) cin >> A[i]; V p2(N); p2[0] = 1; rep(i, N - 1) p2[i + 1] = p2[i] * 2; mint ans = 0; rep(i, N) ans += A[i] * (p2[N - 1 - i] - 1); rep(i, N) ans -= A[i] * (p2[i] - 1); cout << ans.val() << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); int tt = 1; while (tt--) solve(); return 0; }