#include<bits/stdc++.h> #define int long long //不开 ll 见祖宗 #define p 998244353 usingnamespace std; int n, a[500005], h[500005], pre[500005], inv[500005], ans;
signedmain(){ cin >> n; h[0] = pre[0] = 0; inv[1] = 1; for (int i = 2; i <= n; i++) { inv[i] = (p - (p / i) * inv[p % i] % p) % p; //求逆元 } for (int i = 1; i <= n; i++) { h[i] = (h[i - 1] + inv[i]) % p; //调和级数 pre[i] = (pre[i - 1] + h[i]) % p; //级数的前缀和 } for (int i = 1; i <= n; i++) { cin >> a[i]; ans += a[i] * (pre[n] - pre[n - i] - pre[i - 1] + p * 2) % p; //这里加 p * 2 是因为减了两次 ans %= p; } cout << ans; return0; }