#include #include using namespace std; const long long mod = 998244353; int main(){ int n;cin>>n; vector A(n); for(int i = 0; n > i; i++)cin>>A[i]; vector B(n-1); long long sm = 0; for(int i = 0; n-1 > i; i++){ B[i] = A[i]-A[i+1]; sm += B[i]; } long long tmp = sm; long long width = sm; long long nw = 1; long long ans = 0; for(int i = 0; n-1 > i; i++){ ans = (ans + width * nw + mod)%mod; if((n-1)/2 >= i){ tmp -= (B[i]+B[n-2-i]); width = (width+tmp)%mod; }else{ width = (width-tmp+mod)%mod; tmp += (B[i]+B[n-2-i]); } nw = (nw*2)%mod; } cout << ans << endl; }