#include using namespace std; #include using namespace atcoder; using mint = modint998244353; int main () { int N; cin >> N; std::vector A(N) ; for (auto& a : A) cin >> a; int M = 100000; A.push_back(0); for (int i = 1; i <= N; i ++) { M -= max(0, A[i - 1] - A[i]); } if (M < 0) { puts("0"); return 0; } mint a = 1, b = 1, c = 1; for (int i = 1; i <= M + N; i ++) { a *= i; } for (int i = 1; i <= N; i ++) { b *= i; } for (int i = 1; i <= M; i ++) { c *= i; } cout << (a / b / c).val() << endl; }