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 os, sys
from io import BytesIO, IOBase
from collections import Counter

BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
from math import ceil
mod = 10 ** 9 + 7 

for _ in range(int(input())):
    n = int(input())
    array = list(map(int, input().split()))
    set_array = Counter(array)
    """pairs = 0
    s = sum(array)
    mean = s / n
    v = str(mean*(n - 2))
    temp = v.split(".")
    if len(temp[1]) == 1:
        temp = int(temp[0])
    else:
        print(0)
        continue    
    target_sum = s - temp
    if target_sum % 2 == 0:
        if (target_sum//2) in set_array:
            value = set_array[target_sum//2]
            pairs += (value * (value - 1)) // 2
    visited = set()        
    for key, v in set_array.items():
        if key in visited: continue
        required = target_sum - key
        if required in set_array and required != key and required not in visited:
            visited.add(required)
            pairs += set_array[required] * v
    print(pairs)                        

"""

    array.sort()
    s = sum(array)
    mean = s / n
    pairs = 0
    temp = []
    for ele in array:
        if ele in set_array:
            temp.append([ele, set_array[ele]])
            del set_array[ele]       
    if len(temp) == 1:
        ele1, count1 = temp[0]
        if count1 >= 2 and (s - (2 * ele1)) / (n-2) == mean:
            pairs += (count1 * (count1 - 1)) // 2
        print(pairs)
        continue    
    left = 0
    right = len(temp) - 1
    while left < right:
        ele1, count1 = temp[left]
        if count1 >= 2 and (s - (2 * ele1)) / (n-2) == mean:
            pairs += (count1 * (count1 - 1)) // 2
        ele2, count2 = temp[right]
        if count2 >= 2 and (s - (2 * ele2)) / (n-2) == mean:
            pairs += (count2 * (count2 - 1)) // 2
        cs = ele1 + ele2
        new_mean = (s-cs) / (n - 2)
        if new_mean == mean:
            pairs += (count2 * count1)
            left += 1
            right -= 1
        elif new_mean > mean:
            right -= 1
        else:
            left += 1
    print(pairs)            