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.
import java.io.*;
import java.util.Arrays;
import java.util.*;
import java.util.Scanner;
import java.util.StringTokenizer;



public class copy{


    public static boolean checker(long[] arr,long K,long diff)
    {
        long collect=0;
        for(int i=0;i<arr.length;i++)
        {
            if(arr[i]>diff)
                collect+=arr[i]-diff;
        }

        if(collect>=K)
            return true;
        else
            return false;
    }
    public static long search(long[] arr,long K,long R)
    {
        long l=0;
        long r=R;

        while(l<=r)
        {
            long mid=(l+r)/2;

            if(checker(arr,K,mid))
            {
                if(checker(arr,K,mid+1))
                    l=mid+1;
                else
                    return mid;
            }
            else
                r=mid-1;
        }
        return -1;
    }

    static void sieveOfEratosthenes(int n,ArrayList<Integer> arr,ArrayList<Integer> arr1)
    {
        // Create a boolean array
        // "prime[0..n]" and
        // initialize all entries
        // it as true. A value in
        // prime[i] will finally be
        // false if i is Not a
        // prime, else true.
        boolean prime[] = new boolean[n + 1];
        for (int i = 0; i <= n; i++)
            prime[i] = true;

        for (int p = 2; p * p <= n; p++)
        {
            // If prime[p] is not changed, then it is a
            // prime
            if (prime[p] == true)
            {

                // Update all multiples of p
                for (int i = p * p; i <= n; i += p)
                    prime[i] = false;
            }
        }

        // Print all prime numbers
        int x=0;
        for (int i = 2; i <= n; i++)
        {
            if (prime[i] == true)
            {

                arr.add(i);


            }

        }
        System.out.println(arr.size());
    }

    public static boolean check(String s,int K,char ch)
    {
        ArrayList<Integer> arr=new ArrayList<>();
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)==ch)
                arr.add(i);
        }
//        if(K==1 && ch=='z')
//            System.out.println(arr);
        if(arr.size()==0)
            return false;
        if(arr.get(0)>=K)
            return false;
        if(s.length()-1-arr.get(arr.size()-1)>=K)
            return false;
        for(int i=1;i<arr.size();i++)
        {
            if(arr.get(i)-arr.get(i-1)>K)
                return false;
        }
        return true;
    }

    public static int check(long N)
    {
        int sum=0;
        while(N>0)
        {
            sum+=N%10;
            N=N/10;
        }
        return sum;

    }

    public static long call(long N)
    {
        long l=1;
        long r=(long)Math.floor(Math.sqrt(N));
        while(l<=r)
        {
            long mid=(l+r)/2;
            double left=N/(double)(mid)-mid;
            int right=check(mid);
            System.out.println(mid+" "+left+" "+right);
            if(mid==10)
                System.out.println(left+" "+right);
            if(left>right)
                l=mid+1;
            else if(right>left)
                r=mid-1;
            else
                return mid;
        }
        return -1;
    }

    public static int path(ArrayList<ArrayList<Integer>> arr,int X,int parent,int[] gold,PriorityQueue<Integer> pq)
    {
        int max=0;
        ArrayList<Integer> ch=new ArrayList<>();
        for(int i:arr.get(X))
        {
            if(i!=parent)
            {
                ch.add(path(arr,i,X,gold,pq));
            }
        }
        Collections.sort(ch,Collections.reverseOrder());
        for(int i=1;i<ch.size();i++)
            pq.add(ch.get(i));


        if(ch.size()==0)
        return gold[X];
        else
            return ch.get(0)+gold[X];

    }

    public static long fac(long N,long mod)
    {
        if(N==0)
            return 1;
        return ((N%mod)*(fac(N-1,mod)%mod))%mod;
    }






    public static void main(String[] args)throws IOException {
        Reader.init(System.in);
        BufferedWriter output=new BufferedWriter(new OutputStreamWriter(System.out));
        int T=Reader.nextInt();
        for(int m=1;m<=T;m++)
        {
            int N=Reader.nextInt();
            HashMap<Long,Integer> hp=new HashMap<>();
            for(int i=0;i<N;i++)
            {
                long X=Reader.nextLong();
                hp.put(X,hp.getOrDefault(X,0)+1);
            }
            if(N==1)
            {
                output.write(1+"\n");
                continue;
            }
            ArrayList<Long> arr=new ArrayList<>(hp.keySet());
            long mod=998244353;
            Collections.sort(arr);

            if(hp.get(arr.get(arr.size()-1))>=2)
            {
                output.write(fac(N,mod)+"\n");
            }
            else if(hp.get(arr.get(arr.size()-1))==1 && !hp.containsKey(arr.get(arr.size()-1)-1))
            {
                output.write(0+"\n");
            }
            else if(hp.get(arr.get(arr.size()-1))==1)
            {
                int freq=hp.get(arr.get(arr.size()-1)-1);
                double select=0;
                for(int i=0;i<=N-freq-1;i++)
                {
                     //long value=((((((fac(N-freq-1,mod)%mod)*((long)Math.pow(fac(i,mod),-1)%mod))%mod*((long)Math.pow(fac(N-freq-1-i,mod),-1))%mod)%mod)*(fac(freq+i,mod)%mod))%mod*fac(N-freq-i-1,mod)%mod)%mod;
                    double a1=fac(N-freq-1,mod);
                    double a2=Math.pow(fac(i,mod),-1);
                    double a3=Math.pow(fac(N-freq-1-i,mod),-1);
                    //System.out.println(fac(N-freq-1,mod)*Math.pow(fac(i,mod),-1)*Math.pow(fac(N-freq-1-i,mod),-1));
                    double a4=fac(freq+i,mod);
                    double a5=fac(N-freq-i-1,mod);
                    double value=((((a1%mod*a2%mod)%mod*(a3%mod))%mod*a4%mod)%mod*a5%mod)%mod;
                    select=((select%mod)+(value%mod))%mod;


                }
                long fac=fac(N,mod);
                //System.out.println(fac+" "+select);
                output.write((long)(fac%mod-select%mod+mod)%mod+"\n");
            }

        }





        output.flush();


    }






}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}


