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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.lang.reflect.Array;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Random;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.BitSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        CJuryMeeting solver = new CJuryMeeting();
        solver.solve(1, in, out);
        out.close();
    }

    static class CJuryMeeting {
        static final int mod = 998244353;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            var tc = in.nextInt();
            for (int i = 0; i < tc; i++) {
                solution(i, in, out);
            }
        }

        void solution(int testNumber, InputReader in, OutputWriter out) {
            int jm = in.nextInt();
            int[] qs = in.nextSortedIntArray(jm);

            int highest = qs[qs.length - 1];
            int[] qsr = ArrayUtils.removeAllOccurences(qs, highest);
            int numHighest = qs.length - qsr.length;
            var s = Modular.modFact(jm, mod);
            if (numHighest > 1) {
                out.println(s);
                return;
            }

            if (qsr.length == 0) {
                out.println(s);
                return;
            }
            int secondHighest = qsr[qsr.length - 1];
            int[] qsh = ArrayUtils.removeAllOccurences(qsr, secondHighest);
            int numSecondHighest = qsr.length - qsh.length;
            if (highest - secondHighest > 1) {
                out.println(0);
                return;
            }

            // remove all those with the biggest at the front
            s -= Modular.modFact(jm - 1, mod);
            int numChoices = qsh.length;
            for (int i = 1; i < jm - numSecondHighest; i++) {
                int after = i;
                int before = jm - 1 - i;
                s = s - (Modular.modFact(before, mod) * (Permutations.nPr(numChoices, after, mod)));
            }


            out.println(Math.floorMod(s, mod));
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

        public void println(int i) {
            writer.println(i);
        }

    }

    static class Permutations {
        public static long nPr(int N, int K, int mod) {
            if (K > N)
                return 0;
            long res = 1;
            for (int i = N - K + 1; i <= N; ++i) {
                res = (res * i) % mod;
            }
            return res;
        }

    }

    static class Modular {
        static long largestPower(long n, long p) {
            // Initialize result
            long x = 0;

            // Calculate x = n/p + n/(p^2) + n/(p^3) + ....
            while (n > 0) {
                n /= p;
                x += n;
            }
            return x;
        }

        public static long power(long x, long y, long p) {
            long res = 1; // Initialize result
            x = x % p; // Update x if it is more than or
            // equal to p
            while (y > 0) {
                // If y is odd, multiply x with result
                if (y % 2 == 1) {
                    res = (res * x) % p;
                }

                // y must be even now
                y = y >> 1; // y = y/2
                x = (x * x) % p;
            }
            return res;
        }

        public static long modFact(int n, int p) {
            if (n >= p) {
                return 0;
            }

            long res = 1;

            // Use Sieve of Eratosthenes to find all primes
            // smaller than n
            boolean isPrime[] = new boolean[n + 1];
            Arrays.fill(isPrime, true);
            for (int i = 2; i * i <= n; i++) {
                if (isPrime[i]) {
                    for (int j = 2 * i; j <= n; j += i) {
                        isPrime[j] = false;
                    }
                }
            }

            // Consider all primes found by Sieve
            for (int i = 2; i <= n; i++) {
                if (isPrime[i]) {
                    // Find the largest power of prime 'i' that divides n
                    long k = largestPower(n, i);

                    // Multiply result with (i^k) % p
                    res = (res * power(i, k, p)) % p;
                }
            }
            return res;
        }

    }

    static final class EzIntSort {
        private static final double HEAPSORT_DEPTH_COEFFICIENT = 2.0;
        private static final Random rnd = new Random(System.nanoTime());

        private EzIntSort() {
        }

        private static int maxQuickSortDepth(int length) {
            if (length <= 1) {
                return 0;
            }
            int log = Integer.numberOfTrailingZeros(Integer.highestOneBit(length - 1)) + 1;
            return (int) (HEAPSORT_DEPTH_COEFFICIENT * log);
        }

        public static void sort(int[] a) {
            quickSort(a, 0, a.length, 0, maxQuickSortDepth(a.length));
        }

        private static void quickSort(int[] a, int left, int right, int depth, int maxDepth) {
            if (right - left <= 1) {
                return;
            }
            if (depth > maxDepth) {
                heapSort(a, left, right - left);
                return;
            }
            final int pivot = a[left + rnd.nextInt(right - left)];
            int i = left;
            int j = right - 1;
            do {
                while (a[i] < pivot) i++;
                while (pivot < a[j]) j--;
                if (i <= j) {
                    int tmp = a[i];
                    a[i++] = a[j];
                    a[j--] = tmp;
                }
            } while (i <= j);
            quickSort(a, left, j + 1, depth + 1, maxDepth);
            quickSort(a, i, right, depth + 1, maxDepth);
        }

        private static void heapSort(int[] a, int offset, int size) {
            // If size <= 1, nothing is executed
            for (int i = (size >>> 1) - 1; i >= 0; i--) {
                down(a, i, offset, size);
            }
            for (int i = size - 1; i > 0; i--) {
                int tmp = a[offset];
                a[offset] = a[offset + i];
                a[offset + i] = tmp;
                down(a, 0, offset, i);
            }
        }

        private static void down(int[] a, int index, int offset, int size) {
            final int element = a[offset + index];
            final int firstLeaf = (size >>> 1);
            while (index < firstLeaf) {
                int largestChild = (index << 1) + 1;
                if (largestChild + 1 < size && a[offset + largestChild + 1] > a[offset + largestChild]) {
                    largestChild++;
                }
                if (a[offset + largestChild] <= element) {
                    break;
                }
                a[offset + index] = a[offset + largestChild];
                index = largestChild;
            }
            a[offset + index] = element;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; ++i) array[i] = nextInt();
            return array;
        }

        public int[] nextSortedIntArray(int n) {
            int array[] = nextIntArray(n);
            EzIntSort.sort(array);
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class ArrayUtils {
        public static final int INDEX_NOT_FOUND = -1;

        public static int getLength(final Object array) {
            if (array == null) {
                return 0;
            }
            return Array.getLength(array);
        }

        public static BitSet indexesOf(final int[] array, final int valueToFind) {
            return indexesOf(array, valueToFind, 0);
        }

        public static BitSet indexesOf(final int[] array, final int valueToFind, int startIndex) {
            final BitSet bitSet = new BitSet();

            if (array == null) {
                return bitSet;
            }

            while (startIndex < array.length) {
                startIndex = indexOf(array, valueToFind, startIndex);

                if (startIndex == INDEX_NOT_FOUND) {
                    break;
                }

                bitSet.set(startIndex);
                ++startIndex;
            }

            return bitSet;
        }

        public static int indexOf(final int[] array, final int valueToFind, int startIndex) {
            if (array == null) {
                return INDEX_NOT_FOUND;
            }
            if (startIndex < 0) {
                startIndex = 0;
            }
            for (int i = startIndex; i < array.length; i++) {
                if (valueToFind == array[i]) {
                    return i;
                }
            }
            return INDEX_NOT_FOUND;
        }

        static Object removeAll(final Object array, final BitSet indices) {
            if (array == null) {
                return null;
            }

            final int srcLength = getLength(array);
            // No need to check maxIndex here, because method only currently called from removeElements()
            // which guarantee to generate only valid bit entries.
//        final int maxIndex = indices.length();
//        if (maxIndex > srcLength) {
//            throw new IndexOutOfBoundsException("Index: " + (maxIndex-1) + ", Length: " + srcLength);
//        }
            final int removals = indices.cardinality(); // true bits are items to remove
            final Object result = Array.newInstance(array.getClass().getComponentType(), srcLength - removals);
            int srcIndex = 0;
            int destIndex = 0;
            int count;
            int set;
            while ((set = indices.nextSetBit(srcIndex)) != -1) {
                count = set - srcIndex;
                if (count > 0) {
                    System.arraycopy(array, srcIndex, result, destIndex, count);
                    destIndex += count;
                }
                srcIndex = indices.nextClearBit(set);
            }
            count = srcLength - srcIndex;
            if (count > 0) {
                System.arraycopy(array, srcIndex, result, destIndex, count);
            }
            return result;
        }

        public static int[] removeAllOccurences(final int[] array, final int element) {
            return (int[]) removeAll((Object) array, indexesOf(array, element));
        }

        public ArrayUtils() {
        }

    }
}

