// Problem: No.2792 Security Cameras on Young Diagram // Group: yukicoder // URL: https://yukicoder.me/problems/no/2792 // Memory Limit: 512 MB // Time Limit: 2000 ms // Author: lingfunny // // Powered by CP Editor (https://cpeditor.org) #include using namespace std; const int mxn = 1e5 + 10, N = 1e5 + 2; const int mod = 998244353; int n, a[mxn], ans, fct[mxn * 2], ift[mxn * 2]; int S(int x) { return 1ll * x * (x + 1) / 2 % mod; } int qpow(int x, int k) { int res = 1; while (k) { if (k & 1) res = 1ll * res * x % mod; k >>= 1, x = 1ll * x * x % mod; } return res; } int C(int n, int m) { return 1ll * fct[n] * ift[m] % mod * ift[n - m] % mod; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", a + i); fct[0] = 1; for (int i = 1; i <= N * 2; ++i) fct[i] = 1ll * fct[i - 1] * i % mod; ift[N * 2] = qpow(fct[N * 2], mod - 2); for (int i = N * 2 - 1; ~i; --i) ift[i] = 1ll * ift[i + 1] * (i + 1) % mod; ans = a[1] + 1; for (int i = 2; i <= n; ++i) { // a[i] >= x[i] >= x[i - 1] >= ... >= x[1] >= 1 // a[i] + i >= x[i] + i > x[i - 1] + i -1 > .. > x[1] + 1 >= 2 ans += C(a[i] + i - 1, i); // printf("ans += %d\n", C(a[i] + i - 1, i)); ans %= mod; } printf("%d\n", ans); return 0; }