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


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

public class Main {

    static class CP {

        static boolean isPrime(long n) {
            if (n <= 1)
                return false;
            if (n == 2 || n == 3)
                return true;
            if (n % 2 == 0 || n % 3 == 0)
                return false;
            for (int i = 5; i * i <= n; i += 6) {
                if (n % i == 0 || n % (i + 2) == 0)
                    return false;
            }
            return true;
        }

        static int ifnotPrime(int prime[], int x) {

            return (prime[x / 64] & (1 << ((x >> 1) & 31)));
        }

        static void makeComposite(int prime[], int x) {

            prime[x / 64] |= (1 << ((x >> 1) & 31));
        }

        static ArrayList<Integer> bitWiseSieve(int n) {
            ArrayList<Integer> al = new ArrayList<Integer>();
            int prime[] = new int[n / 64 + 1];


            for (int i = 3; i * i <= n; i += 2) {

                if (ifnotPrime(prime, i) == 0)
                    for (int j = i * i, k = i << 1;
                         j < n; j += k)
                        makeComposite(prime, j);
            }

            al.add(2);

            for (int i = 3; i <= n; i += 2)
                if (ifnotPrime(prime, i) == 0)
                    al.add(i);

            return al;
        }

        static List<Integer> sieve(long size) {
            ArrayList<Integer> pr = new ArrayList<Integer>();
            boolean prime[] = new boolean[(int) size];
            for (int i = 2; i < prime.length; i++) prime[i] = true;
            for (int i = 2; i * i < prime.length; i++) {
                if (prime[i]) {
                    for (int j = i * i; j < prime.length; j += i) {
                        prime[j] = false;
                    }
                }
            }
            for (int i = 2; i < prime.length; i++) if (prime[i]) pr.add(i);
            return pr;
        }

        static long binary_Expo(long a, long b) {
            long res = 1;
            while (b != 0) {
                if ((b & 1) == 1) {
                    res *= a;
                    --b;
                }
                a *= a;
                b /= 2;
            }
            return res;
        }

        static long Modular_Expo(long a, long b) {
            long res = 1;
            while (b != 0) {
                if ((b & 1) == 1) {
                    res = (res * a) % 1000000007;
                    --b;
                }
                a = (a * a) % 1000000007;
                b /= 2;
            }
            return res;
        }

        static int i_gcd(int a, int b) {
            while (true) {
                if (b == 0)
                    return a;
                int c = a;
                a = b;
                b = c % b;
            }
        }

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

        static long ceil_div(long a, long b) {
            return (a + b - 1) / b;
        }

        static int getIthBitFromInt(int bits, int i) {
            return (bits >> (i - 1)) & 1;
        }

        static long upper_Bound(long a[], long x) {
            long l = -1, r = a.length;
            while (l + 1 < r) {
                long m = (l + r) >>> 1;
                if (a[(int) m] <= x)
                    l = m;
                else
                    r = m;
            }
            return l + 1;
        }

        static int upper_Bound(List<Integer> a, int x) {
            int l = -1, r = a.size();
            while (l + 1 < r) {
                int m = (l + r) >>> 1;
                if (a.get(m) <= x)
                    l = m;
                else
                    r = m;
            }
            return l + 1;
        }

        static int lower_Bound(int a[], int x) {
            int l = -1, r = a.length;
            while (l + 1 < r) {
                int m = (l + r) >>> 1;
                if (a[(int) m] >= x)
                    r = m;
                else
                    l = m;
            }
            return r;
        }

        static long bsh(long a[], long t) {
            long ans = 0;
            int i = 0, j = a.length - 1;
            while (i <= j) {
                int mid = i + (j - i) / 2;
                if (a[mid] == t) {
                    ans = a[mid];
                    break;
                } else if (a[mid] > t) {
                    ans = a[mid];
                    j = mid - 1;
                } else {
                    i = mid + 1;
                }
            }
            return ans;
        }

        static long bsl(long a[], long t) {
            long ans = 0;
            int i = 0, j = a.length - 1;
            while (i <= j) {
                int mid = i + (j - i) / 2;
                if (a[mid] == t) {
                    ans = a[mid];
                    break;
                } else if (a[mid] > t) {
                    j = mid - 1;
                } else {
                    ans = a[mid];
                    i = mid + 1;
                }
            }
            return ans;
        }

//        static long lower_bound1(long[] ar,long k)
//        {
//            long s=0;
//            long e=ar.length;
//            while (s !=e)
//            {
//                long mid = s+e>>1;
//                if (ar[(int)mid] <k)
//                {
//                    s=mid+1;
//                }
//                else
//                {
//                    e=mid;
//                }
//            }
//            if(s==ar.length)
//            {
//                return -1;
//            }
//            return s;
//        }

        static int lower_Bound(List<Integer> a, int x)  //closest to the right
        {
            int l = -1, r = a.size();
            while (l + 1 < r) {
                int m = (l + r) >>> 1;
                if (a.get(m) >= x)
                    r = m;
                else
                    l = m;
            }
            return r;
        }

        static boolean isSquarefactor(int x, int factor, int target) {
            int s = (int) Math.round(Math.sqrt(x));
            return factor * s * s == target;
        }

        static boolean isSquare(int x) {
            int s = (int) Math.round(Math.sqrt(x));
            return x * x == s;
        }

        static void sort(int a[]) // heap sort
        {
            PriorityQueue<Integer> q = new PriorityQueue<>();
            for (int i = 0; i < a.length; i++)
                q.add(a[i]);
            for (int i = 0; i < a.length; i++)
                a[i] = q.poll();
        }

        static void shuffle(int[] in) {
            for (int i = 0; i < in.length; i++) {
                int idx = (int) (Math.random() * in.length);
                fast_swap(in, idx, i);
            }
        }

        static int[] computeLps(String pat) {
            int len = 0, i = 1, m = pat.length();
            int lps[] = new int[m];
            lps[0] = 0;
            while (i < m) {
                if (pat.charAt(i) == pat.charAt(len)) {
                    ++len;
                    lps[i] = len;
                    ++i;
                } else {
                    if (len != 0) {
                        len = lps[len - 1];
                    } else {
                        lps[i] = len;
                        ++i;
                    }
                }
            }
            return lps;
        }

        static void kmp(String s, String pat) {
            int n = s.length(), m = pat.length();
            int lps[] = computeLps(pat);
            int i = 0, j = 0;
            while (i < n) {
                if (s.charAt(i) == pat.charAt(j)) {
                    i++;
                    j++;

                } else {
                    if (j != 0) {
                        j = lps[j - 1];
                    } else {
                        i++;
                    }
                }
            }
        }

        static void reverse_ruffle_sort(int a[]) {
            shuffle(a);
            Arrays.sort(a);
            for (int l = 0, r = a.length - 1; l < r; ++l, --r)
                fast_swap(a, l, r);

        }

        static void ruffle_sort(int a[]) {
            shuffle(a);
            Arrays.sort(a);
        }

        static int getMax(int arr[], int n) {
            int mx = arr[0];
            for (int i = 1; i < n; i++)
                if (arr[i] > mx)
                    mx = arr[i];
            return mx;
        }

        static ArrayList<Long> primeFactors(long n) {
            ArrayList<Long> al = new ArrayList<>();
            while (n % 2 == 0) {
                al.add(2L);
                n /= 2L;
            }

            for (int i = 3; (long) i * i <= n; i += 2) {
                while ((n % i == 0)) {
                    al.add((long) i);
                    n /= i;
                }
            }

            if (n > 2) {
                al.add(n);
            }
            return al;
        }

        static int[] z_function(String s) {
            int n = s.length(), z[] = new int[n];

            for (int i = 1, l = 0, r = 0; i < n; ++i) {
                if (i <= r)
                    z[i] = Math.min(z[i - l], r - i + 1);

                while (i + z[i] < n && s.charAt(z[i]) == s.charAt(i + z[i]))
                    ++z[i];

                if (i + z[i] - 1 > r) {
                    l = i;
                    r = i + z[i] - 1;
                }
            }
            return z;
        }

        static void swap(int a[], int idx1, int idx2) {
            a[idx1] += a[idx2];
            a[idx2] = a[idx1] - a[idx2];
            a[idx1] -= a[idx2];
        }

        static void fast_swap(int[] a, int idx1, int idx2) {
            if (a[idx1] == a[idx2])
                return;

            a[idx1] ^= a[idx2];
            a[idx2] ^= a[idx1];
            a[idx1] ^= a[idx2];
        }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

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

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    static String addChar(String s, int n, String ch) {
        String result =String.join("", Collections.nCopies(n, ch))+s;
        return result;
    }

    static long sum(int[] arr) {
        long s = 0;
        for (int i = 0; i < arr.length; i++) {
            s += arr[i];
        }
        return s;
    }

    static void printArr(int[] arr) {
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

//    private static long getFib(int arr[],int n) {
//
//        if(n<=2) return arr[n];
//
//        I[1][1]=I[2][2]=1;
//        I[1][2]=I[2][1]=0;
//
//        T[1][1]=0;
//        T[1][2]=T[2][1]=T[2][2]=1;
//
//        n=n-1;
//        while(n>0)
//        {
//            if(n%2==1)
//            {
//                mul(I,T,2);
//                --n;
//            }
//            else
//            {
//                mul(T,T,2);
//                n/=2;
//            }
//        }
//        long ans=(arr[1]*I[1][1]+arr[2]*I[2][1])%mod;
//        return ans;
//    }

    private static void mul(long[][] a, long[][] b, int dim)
    {
        long res[][]=new long[dim+1][dim+1];

        for(int i=1;i<=dim;i++)
        {
            for(int j=1;j<=dim;j++)
            {
                res[i][j]=0;
                for(int k=1;k<=dim;++k)
                {
                    long num=(a[i][k]*b[k][j])%mod;
                    res[i][j]=(res[i][j]+num)%mod;
                }
            }
        }
        for(int i=1;i<=dim;i++)
        {
            for(int j=1;j<=dim;j++)
            {
                a[i][j]=res[i][j];
            }
        }
    }

    static void py() {
        System.out.println("YES");
    }

    static void pn() {
        System.out.println("NO");
    }

    static class DisjointSet {
        int parent[], rank[];

        public DisjointSet(int n) {
            parent = new int[n];
            rank = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
                rank[i] = 0;
            }
        }

        public int find(int i) {
            if (parent[i] == i) {
                return i;
            }
            return parent[i] = find(parent[i]);
        }

        public void union(int a, int b) {
            int x = find(a);
            int y = find(b);
            if (x == y) {
                return;
            }
            if (rank[x] < rank[y]) {
                parent[x] = y;
            } else if (rank[y] < rank[x]) {
                parent[y] = x;
            } else {
                parent[y] = x;
                rank[x]++;
            }
        }
    }

    static class Pair {
        int x,y;

        public Pair(int x,int y) {
            this.x=x;
            this.y=y;
        }
    }
    static int mod=1000000007;

//    int n=sc.nextInt();
//            char ch=sc.nextToken().charAt(0);
//            String s=sc.nextToken();
//            int issorted=1,ind=0,even=0,odd=0;
//            for(int i=0;i<n;i++)
//            {
//                if(s.charAt(i)!=ch)
//                {
//                    issorted=0;
//                }
//            }
//            if(issorted==1)
//            {
//                System.out.println(0);
//            }
//            else
//            {
//                s="#"+s;
//                for(int x=1;x<=n;++x)
//                {
//                    for(int j=1;j)
//                }
//                else
//                {
//                    System.out.println(2);
//                    System.out.println(n+" "+(n-1));
//                }
//            }

    //int[] input = Arrays.stream(br.readLine().split("\\s+")).mapToInt(Integer::parseInt).toArray();

    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            long sum=0;
            int arr[]=new int[n];
            for(int i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                sum+=arr[i];
            }
            long req=2*(sum/n);
            if((sum*(n-2))!=(sum-req)*n)
            {
                System.out.println(0);
            }
            else
            {
                System.out.println(getPairsCount(n,req,arr));
            }
        }
    }

    static int getPairsCount(int n, long sum,int arr[])
    {
        HashMap<Integer, Integer> hm = new HashMap<>();

        for (int i = 0; i < n; i++) {

            if (!hm.containsKey(arr[i]))
                hm.put(arr[i], 0);

            hm.put(arr[i], hm.get(arr[i]) + 1);
        }
        int twice_count = 0;


        for (int i = 0; i < n; i++) {
            if (hm.get((int)sum - arr[i]) != null)
                twice_count += hm.get((int)sum - arr[i]);


            if (sum - arr[i] == arr[i])
                twice_count--;
        }

        return twice_count / 2;
    }

}




