Monocarp has got an array a consisting of n integers. Let's denote k as the mathematic mean of these elements (note that it's possible that k is not an integer). 

The mathematic mean of an array of n elements is the sum of elements divided by the number of these elements (i. e. sum divided by n).

Monocarp wants to delete exactly two elements from a so that the mathematic mean of the remaining (n - 2) elements is still equal to k.

Your task is to calculate the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).

Input

The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.

The first line of each testcase contains one integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in the array.

The second line contains a sequence of integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{9}), where a_i is the i-th element of the array.

The sum of n over all testcases doesn't exceed 2 ⋅ 10^5.

Output

Print one integer — the number of pairs of positions [i, j] (i < j) such that if the elements on these positions are deleted, the mathematic mean of (n - 2) remaining elements is equal to k (that is, it is equal to the mathematic mean of n elements of the original array a).

Example

Input


4
4
8 8 8 8
3
50 20 10
5
1 4 7 3 5
7
1 2 3 4 5 6 7


Output


6
0
2
3

Note

In the first example, any pair of elements can be removed since all of them are equal.

In the second example, there is no way to delete two elements so the mathematic mean doesn't change.

In the third example, it is possible to delete the elements on positions 1 and 3, or the elements on positions 4 and 5.
1
3
228 1337 228

0

//package codeforces;

import java.io.*;
import java.util.*;

public class ProblemB {
    private final static FastScanner scanner = new FastScanner();
    private final static long M = 1000000007L;

    public static void main(String[] args) throws IOException {
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            solve();
        }
//        solve();
    }

    public static void solve() {
        long n = scanner.nextLong();
        long[] arr = new long[(int) n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextLong();
            sum += arr[i];
        }
        double k = ((double) sum / n);
        long pairs = 0;
        Map<Long, List<Integer>> indexes = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (!indexes.containsKey(arr[i])) {
                indexes.put(arr[i], new ArrayList<>());
            }
            indexes.get(arr[i]).add(i);
        }
        indexes.forEach((key, value) -> Collections.sort(value));
        for (int i = 0; i < n; i++) {
            long diff = sum - arr[i];
            long divide = (long) (k * (n - 2));
            List<Integer> idx = indexes.get(diff - divide);
            if (idx == null || idx.size() == 0) continue;
            int start = Collections.binarySearch(idx, i);
            if (start < 0) {
                int pushed = -start;
                pushed--;
                pairs += idx.size() - pushed;
            } else {
                pairs += idx.size() - start - 1;
            }
//            if (pushed > idx.size()) continue;
//            if(start < 0) pairs += idx.size();
//            else pairs += idx.size() - start - 1;
        }
        System.out.println(pairs);
    }
    /*public static void solve() {
        int n = scanner.nextInt();
        int[][] week = new int[n][5];
        int[] sum = new int[5];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 5; j++) {
                week[i][j] = scanner.nextInt();
                sum[j] += week[i][j];
            }
        }
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (i == j) continue;
                if (sum[i] >= n / 2 && sum[j] >= n / 2) {
                    int[] temp = Arrays.copyOf(sum, 5);
                    for (int k = 0; k < n; k++) {
                        if (week[k][i] == 1 && week[k][j] == 1) temp[j]--;
                    }
                    if (temp[j] >= n / 2) {
                        System.out.println("YES");
                        return;
                    }
                }
            }
        }
        System.out.println("NO");
    }*/

//    public static void solve() {
//        long n = scanner.nextLong();
//        long k = scanner.nextLong();
//        List<Long> sequence = new ArrayList<>();
//        int pow = 0;
//        while (k > 0) {
//            long res = moduloPower(n, pow, M);
//            pow++;
//            sequence.add(res % M);
//            k--;
//            if (k == 0) {
//                System.out.println(sequence.get(sequence.size() - 1));
//                return;
//            }
//            int size = sequence.size();
//            for (int i = 0; i < size - 1; i++) {
//                long num = sequence.get(i);
//                sequence.add((res + num) % M);
//                k--;
//                if (k == 0) {
//                    System.out.println(sequence.get(sequence.size() - 1));
//                    return;
//                }
//            }
//        }
//    }

    public static long getManhattanDistance(long x1, long y1, long x2, long y2) {
        return Math.abs(x1 - x2) + Math.abs(y1 - y2);
    }

    public static long lcm(long number1, long number2) {
        if (number1 == 0 || number2 == 0) {
            return 0;
        }
        long absNumber1 = Math.abs(number1);
        long absNumber2 = Math.abs(number2);
        long absHigherNumber = Math.max(absNumber1, absNumber2);
        long absLowerNumber = Math.min(absNumber1, absNumber2);
        long lcm = absHigherNumber;
        while (lcm % absLowerNumber != 0) {
            lcm += absHigherNumber;
        }
        return lcm;
    }

    static void swap(int[] arr, int l, int r) {
        int temp = arr[l];
        arr[l] = arr[r];
        arr[r] = temp;
    }

    static void swap(long[] arr, int l, int r) {
        long temp = arr[l];
        arr[l] = arr[r];
        arr[r] = temp;
    }

    private static int getTickSize(char[][] mat, int i, int j) {
        if (i < 0 || j < 0 || i >= mat.length || j >= mat[0].length || mat[i][j] == '.') return 0;
        mat[i][j] = '.';
        return Math.min(getTickSize(mat, i - 1, j - 1), getTickSize(mat, i - 1, j + 1));
    }

    private static Boolean isSquare(long x) {
        long y = (long) Math.sqrt(x);
        return y * y == x;
    }

    private static int getMax(int[] arr) {
        int[] copy = Arrays.copyOf(arr, arr.length);
        Arrays.sort(copy);
        return copy[arr.length - 1];
    }

    private static double customLog(double logNumber, double base) {
        return Math.log(logNumber) / Math.log(base);
    }


    static int checkSim(String n1, String n2, int i, int j) {
        if (i >= n1.length() || j >= n2.length()) return 0;
        if (n1.charAt(i) == n2.charAt(j)) return 1 + checkSim(n1, n2, i + 1, j + 1);
        return checkSim(n1, n2, i + 1, j);
    }

    static int computeXOR(int n) {
        if (n % 4 == 0)
            return n;
        if (n % 4 == 1)
            return 1;
        if (n % 4 == 2)
            return n + 1;
        return 0;
    }

    static boolean isPowerOfTwo(long n) {
        if (n == 0)
            return false;

        double v = Math.log(n) / Math.log(2);
        return (long) (Math.ceil(v)) == (long) (Math.floor(v));
    }

    static boolean isPrime(int n) {
        if (n <= 1)
            return false;

        else if (n == 2)
            return true;

        else if (n % 2 == 0)
            return false;

        for (int i = 3; i <= Math.sqrt(n); i += 2) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

    static boolean checkSorted(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            if (arr[i - 1] > arr[i]) return false;
        }
        return true;
    }

    static void print(int from, int to) {
        if (from <= to) {
            for (int i = from; i <= to; i++) {
                System.out.print(i + " ");
            }
        } else {
            System.out.print(from + " ");
            for (int i = 1; i <= to; i++) {
                System.out.print(i + " ");
            }
        }
    }

    static long moduloMultiplication(long a, long b, long mod) {
        long res = 0;
        a %= mod;
        while (b > 0) {
            if ((b & 1) > 0) {
                res = (res + a) % mod;
            }
            a = (2 * a) % mod;
            b >>= 1;
        }
        return res;
    }

    static long moduloPower(long x, long y, long p) {
        long res = 1L;
        x = x % p;
        while (y > 0) {
            if ((y & 1) > 0)
                res = (res * x) % p;

            y = y >> 1;
            x = (x * x) % p;
        }
        return res % p;
    }

    static int lowerBound(long a[], long x) { // x is the target value or key
        int l = -1, r = a.length;
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a[m] >= x) r = m;
            else l = m;
        }
        return r;
    }

    static int upperBound(long a[], long x) {// x is the key or target value
        int l = -1, r = a.length;
        while (l + 1 < r) {
            int m = (l + r) >>> 1L;
            if (a[m] <= x) l = m;
            else r = m;
        }
        return l + 1;
    }

    static long upperBound(long[] arr, int start, int end, long k) {
        int N = end;
        while (start < end) {
            int mid = start + (end - start) / 2;
            if (k >= arr[mid]) {
                start = mid + 1;
            } else {
                end = mid;
            }
        }
        if (start < N && arr[start] <= k) {
            start++;
        }
        return start;
    }

    static long lowerBound(long[] arr, int start, int end, long k) {
        int N = end;
        while (start < end) {
            int mid = start + (end - start) / 2;
            if (k <= arr[mid]) {
                end = mid;
            } else {
                start = mid + 1;
            }
        }
        if (start < N && arr[start] < k) {
            start++;
        }
        return start;
    }

    static int getDistance(int x1, int y1, int x2, int y2) {
        return Math.abs(x1 - x2) + Math.abs(y1 - y2);
    }

    static int sumOfNNaturalNumbers(int n) {
        return (n * (n + 1)) / 2;
    }

    static long sumOfNNaturalNumbers(long n) {
        return (n * (n + 1)) / 2;
    }

    static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }


    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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