#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7, p = 998244353;
int n, sum, ans, opt, w[N], cnt[N];
long long fac[N], ifac[N];
inline int read() {
  int num = 0;
  char g = getchar();
  while (g < 48 || 57 < g) g = getchar();
  while (47 < g && g < 58)
    num = (num << 1) + (num << 3) + g - 48, g = getchar();
  return num;
}
inline long long getans(int a, int b) {
  if (a < b) return 0;
  return fac[a] * ifac[b] % p * ifac[a - b] % p;
}
int main() {
  n = read();
  int tp = 1;
  fac[0] = ifac[0] = ifac[1] = 1, opt = 1;
  for (int i = 1; i <= n; i++) w[i] = read(), sum += w[i];
  sort(w + 1, w + n + 1);
  for (int i = 2; i <= 1e6; i++) ifac[i] = ifac[p % i] * (p - p / i) % p;
  for (int i = 1; i <= 1e6; i++)
    fac[i] = fac[i - 1] * i % p, ifac[i] = ifac[i - 1] * ifac[i] % p;
  for (int i = 1; i <= sum; i++) {
    ans += cnt[i % n];
    while (w[tp] < i && tp <= n) tp++, ans++, cnt[i % n]++;
    if (ans > i || tp > n) break;
    opt = (opt + getans(i - ans + n - 1, n - 1) -
           getans(i - ans + tp - 2, n - 1)) %
          p;
  }
  cout << (opt + p) % p << endl;
}
