#include <bits/stdc++.h>
using namespace std;
void exgcd(int a, int b, int& x, int& y) {
  if (!b) {
    x = 1, y = 0;
  } else {
    exgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
}
int inv(int a, int n) {
  int x, y;
  exgcd(a, n, x, y);
  return (x < 0) ? (x + n) : (x);
}
const int Mod = 998244353;
template <const int Mod = ::Mod>
class Z {
 public:
  int v;
  Z() : v(0) {}
  Z(int x) : v(x) {}
  Z(long long x) : v(x % Mod) {}
  friend Z operator+(const Z& a, const Z& b) {
    int x;
    return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
  }
  friend Z operator-(const Z& a, const Z& b) {
    int x;
    return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
  }
  friend Z operator*(const Z& a, const Z& b) { return Z(a.v * 1ll * b.v); }
  friend Z operator~(const Z& a) { return inv(a.v, Mod); }
  friend Z operator-(const Z& a) { return Z(0) - a; }
  Z& operator+=(Z b) { return *this = *this + b; }
  Z& operator-=(Z b) { return *this = *this - b; }
  Z& operator*=(Z b) { return *this = *this * b; }
  friend bool operator==(const Z& a, const Z& b) { return a.v == b.v; }
};
Z<> qpow(Z<> a, int p) {
  Z<> rt = Z<>(1), pa = a;
  for (; p; p >>= 1, pa = pa * pa) {
    if (p & 1) {
      rt = rt * pa;
    }
  }
  return rt;
}
const int N = 1e5 + 5, V = 2e6 + 5;
int n, sum;
int a[N], c[N];
Z<> fac[V], _fac[V];
void init_fac(int n) {
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i;
  }
  _fac[n] = ~fac[n];
  for (int i = n; i; i--) {
    _fac[i - 1] = _fac[i] * i;
  }
}
Z<> comb(int n, int m) {
  return (n < m) ? (0) : (fac[n] * _fac[m] * _fac[n - m]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    sum += a[i];
  }
  init_fac(sum + n);
  int cri = 0;
  sort(a + 1, a + n + 1);
  for (int i = 1; i < n; i++) {
    if (a[i + 1] < i) {
      cri = i;
      break;
    }
  }
  Z<> ans = 0;
  if (cri) {
    int num = 0;
    for (int i = 0; i < cri; i++) {
      while (num < n && a[num + 1] < i) num++;
      ans += comb(i - num + n - 1, n - 1);
    }
  } else {
    sum = 1;
    for (int i = 1; i <= n; i++) {
      sum += a[i] / n;
      c[a[i] % n]++;
    }
    for (int i = 0; i < n; i++) {
      sum += c[n - i] - 1;
      ans += comb(sum + n - 1, n - 1);
    }
  }
  printf("%d\n", ans.v);
  return 0;
}
