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.*;

public class C {
    //--------------------------INPUT READER--------------------------------//
    static class fs {
        public BufferedReader br;
        StringTokenizer st = new StringTokenizer("");

        public fs() { this(System.in); }
        public fs(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String next() {
            while (!st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }

        int ni() { return Integer.parseInt(next()); }
        long nl() { return Long.parseLong(next()); }
        double nd() { return Double.parseDouble(next()); }
        String ns() { return next(); }

        int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }
    }
    //-----------------------------------------------------------------------//

    //---------------------------PRINTER-------------------------------------//
    static class Printer {
        static PrintWriter w;
        public Printer() {this(System.out);}
        public Printer(OutputStream os) {
            w = new PrintWriter(os);
        }
        public void p(int i) {w.println(i);};
        public void p(long l) {w.println(l);};
        public void p(double d) {w.println(d);};
        public void p(String s) { w.println(s);};
        public void pr(int i) {w.println(i);};
        public void pr(long l) {w.print(l);};
        public void pr(double d) {w.print(d);};
        public void pr(String s) { w.print(s);};
        public void pl() {w.println();};
        public void close() {w.close();};
    }
    //------------------------------------------------------------------------//

    //--------------------------VARIABLES------------------------------------//
    static fs sc = new fs();
    static OutputStream outputStream = System.out;
    static Printer w = new Printer(outputStream);
    static long mod = 998_244_353;
    static long[] fact;
    //-----------------------------------------------------------------------//

    //--------------------------ADMIN_MODE-----------------------------------//
    private static void ADMIN_MODE() throws IOException {
        if (System.getProperty("ONLINE_JUDGE") == null) {
            w = new Printer(new FileOutputStream("output.txt"));
            sc = new fs(new FileInputStream("input.txt"));
        }
    }
    //-----------------------------------------------------------------------//

    //----------------------------START--------------------------------------//
    public static void main(String[] args)
            throws IOException {

        ADMIN_MODE();
        fact = new long[1000000];
        fact[0] = 0;
        fact[1] = 1;
        for(int i = 2; i < 1000000; i++) {
            fact[i] = fact[i-1]*i;
            fact[i] %= mod;
        }

        int t = sc.ni();
        while(t-->0)
            solve();


        w.close();
    }

    static void solve() throws IOException {
        int n = sc.ni();
        Long[] arr = new Long[n];
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nl();
        }
        Arrays.sort(arr);
        long pre = arr[0];
        List<Long> count = new ArrayList<>();
        count.add(1L);
        long prepre = arr[0];
        for(int i = 1; i < n; i++) {
            if(arr[i] == pre) {
                count.set(count.size()-1, count.get(count.size()-1)+1);
            } else {
                prepre = pre;
                pre = arr[i];
                count.add(1L);
            }
        }
        long ans = 1;
        ans = fact[n];

        int nn = count.size();
        if(count.size() == 1) {
            w.p(ans);
            return;
        }

        if(arr[n-1].equals(arr[n-2])) {
            w.p(0);
            return;
        }

        if(count.get(nn-1) > 1) {
            w.p(ans);
            return;
        }

        long extra = 0;
        long st = count.get(nn-2);
        for(long i = st; i <= n-1; i++) {
            long curr1 = fact[(int)i];
            if(i-st >= 1 && i != n-1) {
                curr1 *= (ncr(n-st-1, i - st));
                curr1 %= mod;
            }
            if(n-i-1 > 0) {
                curr1 *= fact[(int) (n-i-1)];
                curr1 %= mod;
            }
            curr1 %= mod;
            extra += curr1;
            extra %= mod;
        }

        w.p((ans-extra+mod)%mod);
    }

    // region pow(a, b, mod) -> a^b
    static long fastP(long b, long x, long mod) {
        if (x == 0) return 1;
        if (x == 1) return b;
        if (x % 2 == 0) return fastP(b * b % mod, x / 2, mod) % mod;

        return b * fastP(b * b % mod, x / 2, mod) % mod;
    }
    // endregion

    static long ncr(long n, long r) {
        long num = fact[(int)n];
        long den = fact[(int)(n-r)];
        den%=mod;
        den *= fact[(int)(r)];
        den%=mod;
        return ((num%mod)*fastP((den%mod),mod-2, mod))%mod;
    }
}