#include using namespace std; #define int long long signed main(){ int N; cin>>N; vector S(N+1,0); int mod = 998244353; for(int i=1;i<=N;i++){ int x; cin>>x; S[i] = S[i-1]+x; S[i] %= mod; } int ans = mod; int now = 1; for(int i=2;i<=N;i++){ ans += now*((S[N-i+1]-S[N]+S[i-1]+mod*mod)%mod)%mod; now *= 2; now %= mod; } cout<