#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class t, class u>
void chmax(t& first, u second) {
  if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
  if (second < first) first = second;
}
template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;
using pi = pair<ll, ll>;
using vi = vc<ll>;
template <class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
  return os << "{" << p.first << "," << p.second << "}";
}
template <class t>
ostream& operator<<(ostream& os, const vc<t>& v) {
  os << "{";
  for (auto e : v) os << e << ",";
  return os << "}";
}
using uint = unsigned;
using ull = unsigned long long;
const uint mod = 998244353;
struct mint {
  uint v;
  mint(ll vv = 0) { s(vv % mod + mod); }
  mint& s(uint vv) {
    v = vv < mod ? vv : vv - mod;
    return *this;
  }
  mint operator-() const { return mint() - *this; }
  mint& operator+=(const mint& rhs) { return s(v + rhs.v); }
  mint& operator-=(const mint& rhs) { return s(v + mod - rhs.v); }
  mint& operator*=(const mint& rhs) {
    v = ull(v) * rhs.v % mod;
    return *this;
  }
  mint& operator/=(const mint& rhs) { return *this *= rhs.inv(); }
  mint operator+(const mint& rhs) const { return mint(*this) += rhs; }
  mint operator-(const mint& rhs) const { return mint(*this) -= rhs; }
  mint operator*(const mint& rhs) const { return mint(*this) *= rhs; }
  mint operator/(const mint& rhs) const { return mint(*this) /= rhs; }
  mint pow(ll n) const {
    mint res(1), x(*this);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  mint inv() const { return pow(mod - 2); }
  friend ostream& operator<<(ostream& os, const mint& m) { return os << m.v; }
  bool operator<(const mint& r) const { return v < r.v; }
};
const ll Vmax = (1 << 21) + 10;
mint fact[Vmax], finv[Vmax], inv[Vmax];
void initfact() {
  fact[0] = 1;
  for (ll i = ll(1); i < ll(Vmax); i++) {
    fact[i] = fact[i - 1] * i;
  }
  finv[Vmax - 1] = fact[Vmax - 1].inv();
  for (ll i = Vmax - 2; i >= 0; i--) {
    finv[i] = finv[i + 1] * (i + 1);
  }
  for (ll i = Vmax - 1; i >= 1; i--) {
    inv[i] = finv[i] * fact[i - 1];
  }
}
mint choose(ll n, ll k) { return fact[n] * finv[n - k] * finv[k]; }
mint binom(ll first, ll second) {
  return fact[first + second] * finv[first] * finv[second];
}
mint catalan(ll n) {
  return binom(n, n) - (n - 1 >= 0 ? binom(n - 1, n + 1) : 0);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  initfact();
  ll k;
  cin >> k;
  vi first(k);
  for (ll i = ll(0); i < ll(k); i++) cin >> first[i];
  sort(first.begin(), first.end());
  for (ll i = ll(0); i < ll(k); i++)
    if (i > first[i]) {
      ll mx = first[i];
      ll cnt = 0;
      mint ans = 0;
      for (ll x = ll(0); x < ll(mx + 1); x++) {
        while (first[cnt] < x) cnt++;
        ans += choose(x - cnt + k - 1, k - 1);
      }
      cout << ans << endl;
      return 0;
    }
  ll sum = 0;
  vi cnt(k);
  for (auto v : first) {
    sum += v / k;
    cnt[v % k]++;
  }
  mint ans = 0;
  for (ll i = ll(0); i < ll(k); i++) {
    ans += choose(sum + k - 1, k - 1);
    sum--;
    sum += cnt[k - 1 - i];
  }
  cout << ans << endl;
}
