description: n people gathered to hold a jury meeting of the upcoming competition, the i-th member of the jury came up with a_i tasks, which they want to share with each other.
  
  First, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation p of numbers from 1 to n (an array of size n where each integer from 1 to n occurs exactly once).
  
  Then the discussion goes as follows:
  
    * If a jury member p_1 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. 
    * If a jury member p_2 has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. 
    * ... 
    * If a jury member p_n has some tasks left to tell, then they tell one task to others. Otherwise, they are skipped. 
    * If there are still members with tasks left, then the process repeats from the start. Otherwise, the discussion ends. 
  
  
  
  A permutation p is nice if none of the jury members tell two or more of their own tasks in a row. 
  
  Count the number of nice permutations. The answer may be really large, so print it modulo 998 244 353.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.
  
  The first line of the test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — number of jury members.
  
  The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the number of problems that the i-th member of the jury came up with.
  
  The sum of n over all test cases does not exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case, print one integer — the number of nice permutations, taken modulo 998 244 353.
  
  Example
  
  Input
  
  
  4
  2
  1 2
  3
  5 5 5
  4
  1 3 3 7
  6
  3 4 2 1 3 3
  
  
  Output
  
  
  1
  6
  0
  540
  
  Note
  
  Explanation of the first test case from the example:
  
  There are two possible permutations, p = [1, 2] and p = [2, 1]. For p = [1, 2], the process is the following:
  
    1. the first jury member tells a task; 
    2. the second jury member tells a task; 
    3. the first jury member doesn't have any tasks left to tell, so they are skipped; 
    4. the second jury member tells a task. 
  
  
  
  So, the second jury member has told two tasks in a row (in succession), so the permutation is not nice.
  
  For p = [2, 1], the process is the following:
  
    1. the second jury member tells a task; 
    2. the first jury member tells a task; 
    3. the second jury member tells a task. 
  
  
  
  So, this permutation is nice.
solution: import java.io.*;
  import java.util.*;
  public class eduprac implements Runnable 
  {
  	private boolean console=false;
  
  	long f[]=new long[1000000];
  	long m=998244353;
  	public void solve() 
  	{
  		int i; 	int n=in.ni(); Integer a[]=new Integer[n]; 
  		for(i=0;i<n;i++) a[i]=in.ni();
  		Arrays.sort(a);
  		int b=a[n-1]; int c1=a[n-2];
  		if(b==c1)
  		{
  			out.println(f[n]); return;
  		}
  		else
  		{
  			if(a[n-1]-a[n-2]!=1)
  			{
  				out.println(0); return;
  			}
  			int c=0;
  			for(i=0;i<n;i++)
  			{
  				int v=a[i]; int v2=a[n-2];
  				if(v==v2) c++;
  			}
  			int cf=n-c-1;
  			int start=n-1; long cnt=0;
  			while(start>=c)
  			{
  				long cur = nCr(start,c,m);
  				cnt = (cnt+cur)%m;
  				start--;
  			}
  			cnt = (cnt*f[cf])%m;
  			cnt = (cnt*f[c])%m;
  			long ans= (f[n]-cnt+m)%m;
  			out.println(ans);
  		}
  	}
  	public long power(long a,long b,long mod)
  	{
  		long x = 1, y = a; 
  		while (b > 0)
  		{
  			if (b%2!=0) 
  				x = (x*y)%mod;
  			y = (y*y)%mod; 
  			b /= 2; 
  		} 
  		return x%mod; 
  	}
  	long modinverse(long n, long mod)
  	{ 
  		return power(n, mod-2, mod); 
  	}
  	long nCr(int n, int r, long mod)
  	{ 
  		return (f[n]*((modinverse(f[r], mod) * modinverse(f[n-r], mod)) % mod)) % mod; 
  	}
  	@Override
  	public void run() {
  		try {  init();  } 
  		catch (FileNotFoundException e) {  e.printStackTrace();   }
  
  		f[0]=1; int i;
  		for(i=1;i<f.length;i++)
  		{
  			f[i]=i*f[i-1];
  			f[i]%=m;
  		}
  		int t= in.ni();
  
  		while(t-->0)
  		{
  			solve();
  			out.flush(); 
  		}
  	}
  	private FastInput in;    private PrintWriter out;
  	public static void main(String[] args) throws Exception {	 new eduprac().run();	 }
  
  	private void init() throws FileNotFoundException {
  		InputStream inputStream = System.in; 	 OutputStream outputStream = System.out;
  		try {  if (!console && System.getProperty("user.name").equals("sachan")) {
  			outputStream = new FileOutputStream("/home/sachan/Desktop/output.txt");
  			inputStream = new FileInputStream("/home/sachan/Desktop/input.txt");   	}
  		}	catch (Exception ignored) {	}
  		out = new PrintWriter(outputStream); 	 in = new FastInput(inputStream);
  	}
  	static class FastInput { InputStream obj;
  	public FastInput(InputStream obj) {	this.obj = obj;	}
  	byte inbuffer[] = new byte[1024];  int lenbuffer = 0, ptrbuffer = 0;
  	int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
  	if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
  	try { lenbuffer = obj.read(inbuffer);  }
  	catch (IOException e) { throw new InputMismatchException(); } }    
  	if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
  
  	String ns() { int b = skip();StringBuilder sb = new StringBuilder();
  	while (!(isSpaceChar(b)))	  { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
  
  	int ni() { int num = 0, b;boolean minus = false;
  	while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
  	if (b == '-') { minus = true;b = readByte(); }
  	while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
  		return minus ? -num : num; }b = readByte(); }}
  
  	long nl() { long num = 0;int b;boolean minus = false;
  	while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
  	if (b == '-') { minus = true;b = readByte(); }
  	while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
  		return minus ? -num : num; }b = readByte(); } }
  
  	boolean isSpaceChar(int c) { return (!(c >= 33 && c <= 126)); }
  	int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
  	float nf() {return Float.parseFloat(ns());}
  	double nd() {return Double.parseDouble(ns());}
  	char nc() {return (char) skip();}
  	}
  }