#include <bits/stdc++.h>
using namespace std;
const int N = 1000005, P = 998244353;
using ll = long long;
int n, kk, a[N * 2], p[N * 2];
ll fac[N * 2], ifac[N * 2];
ll C(int n, int m) {
  return n < m || n < 0 || m < 0 ? 0 : fac[n] * ifac[m] % P * ifac[n - m] % P;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> kk;
  n = kk + N;
  for (int i = 1; i <= kk; i++) {
    cin >> a[i];
    for (int j = a[i] + 1; j <= n; j += kk) ++p[j];
  }
  for (int i = 1; i <= n; i++) {
    p[i] += p[i - 1];
    if (p[i] > i) n = i - 1;
  }
  fac[0] = 1;
  for (int i = 1; i <= n + kk; i++) fac[i] = fac[i - 1] * i % P;
  ifac[0] = ifac[1] = 1;
  for (int i = 2; i <= n + kk; i++) ifac[i] = ifac[P % i] * (-P / i + P) % P;
  for (int i = 2; i <= n + kk; i++) ifac[i] = ifac[i - 1] * ifac[i] % P;
  ll ans = 0;
  for (int i = n; i > n - kk && i >= 0; --i)
    ans = (ans + C(i - p[i] + kk - 1, kk - 1)) % P;
  cout << ans << endl;
  return 0;
}
