Problem: At Moscow Workshops ICPC team gets a balloon for each problem they solved first. Team MSU Red Panda got so many balloons that they didn't know how to spend them. So they came up with a problem with them.

There are several balloons, not more than 10^6 in total, each one is colored in one of k colors. We can perform the following operation: choose k-1 balloons such that they are of k-1 different colors, and recolor them all into remaining color. We can perform this operation any finite number of times (for example, we can only perform the operation if there are at least k-1 different colors among current balls).

How many different balloon configurations can we get? Only number of balloons of each color matters, configurations differing only by the order of balloons are counted as equal. As this number can be very large, output it modulo 998244353.

Input

The first line contains a single integer k (2 ≤ k ≤ 10^5) —the number of colors.

The second line contains k integers a_1, a_2, …, a_k (0 ≤ a_i) —initial configuration of balloons. a_i is number of balloons of color i. The total number of balloons doesn't exceed 10^6. In other words,

a_1 + a_2 + a_3 + … + a_k ≤ 10^6.

Output

Output number of possible configurations modulo 998244353.

Examples

Input


3
0 1 2


Output


3


Input


4
1 1 1 1


Output


5

Input


5
0 0 1 2 3


Output


1

Input


3
2 2 8


Output


31

Note

In the first example, there are 3 configurations we can get: [0, 1, 2], [2, 0, 1], [1, 2, 0].

In the second example, we can apply the operation not more than once, and possible configurations are: [1, 1, 1, 1], [0, 0, 0, 4], [0, 0, 4, 0], [0, 4, 0, 0], [4, 0, 0, 0]. 

In the third example, we can't apply any operations, so the only achievable configuration is the starting one.

Solution (in JAVA):

Solution:
// https://codeforces.com/contest/1188/submission/56588689 (rainboy)
import java.io.*;
import java.util.*;

public class CF1188E extends PrintWriter {
	CF1188E() { super(System.out, true); }
	static class Scanner {
		Scanner(InputStream in) { this.in = in; } InputStream in;
		int k, l; byte[] bb = new byte[1 << 15];
		byte getc() {
			if (k >= l) {
				k = 0;
				try { l = in.read(bb); } catch (IOException e) { l = 0; }
				if (l <= 0) return -1;
			}
			return bb[k++];
		}
		int nextInt() {
			byte c = 0; while (c <= 32) c = getc();
			int a = 0;
			while (c > 32) { a = a * 10 + c - '0'; c = getc(); }
			return a;
		}
	}
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1188E o = new CF1188E(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	int d_, x_, y_;
	void gcd_(int a, int b) {
		if (b == 0) {
			d_ = a;
			x_ = 1; y_ = 0;
		} else {
			gcd_(b, a % b);
			int tmp = x_ - (a / b) * y_; x_ = y_; y_ = tmp;
		}
	}
	int inv(int a, int b) {
		gcd_(a, b);
		return x_;
	}
	int[] ff, gg;
	void init(int m) {
		ff = new int[m];
		gg = new int[m];
		for (int j = 0, f = 1; j < m; j++) {
			gg[j] = inv(ff[j] = f, MD);
			f = (int) ((long) f * (j + 1) % MD);
		}
	}
	int choose(int n, int k) {
		return n < k ? 0 : (int) ((long) ff[n] * gg[k] % MD * gg[n - k] % MD);
	}
	void main() {
		int n = sc.nextInt();
		int[] aa = new int[n];
		int a_ = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			a_ = Math.max(a_, aa[i] = a);
		}
		ArrayList[] ii = new ArrayList[a_ + 1];
		for (int a = 0; a <= a_; a++)
			ii[a] = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int a = aa[i];
			ii[a].add(i);
		}
		init(a_ + n);
		boolean[] used = new boolean[n];
		int ans = 0;
		for (int a = 0, b = 0, c = n; ; b++) {
			while (a <= a_ && ii[a].isEmpty())
				a++;
			if (a < b || a > a_)
				break;
			int i = (int) ii[a].remove(ii[a].size() - 1);
			ans = (ans + choose(a - b + n - 1, n - 1)) % MD;
			if (!used[i]) {
				used[i] = true;
				c--;
			} else
				ans = (ans - choose(a - b - c + n - 1, n - 1)) % MD;
			if (a + n <= a_)
				ii[a + n].add(i);
		}
		if (ans < 0)
			ans += MD;
		println(ans);
	}
}