#define _GLIBCXX_DEBUG #include #include #include using namespace atcoder; using namespace std; typedef long long ll; #define rep(i,a,b) for(int i=a;i; using vvi = vector; using li =vector; using lli=vector
  • ; using si =vector; using ssi =vector; const long long INF = 1e18; const long long MOD=998244353; int main() { ll n; cin>>n;ll ans=0; if(n==2){ll a,b;cin>>a>>b;cout<<(a+b)%MOD;return 0;} rep(i,0,n){ll a;cin>>a;a%=MOD; if(i==0||i==1){ll b=n*(n-1)/2-1;b%=MOD;ans+=a*b;ans%=MOD;} else {ll b=(n-i)*(n-i+1)/2;b%=MOD;MOD;ans+=a*(n-i)*b;ans%=MOD;} } cout<