Highway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divided into n sub-tracks. You are given an array a where a_i represents the number of traffic cars in the i-th sub-track. You define the inconvenience of the track as ∑_{i=1}^{n} ∑_{j=i+1}^{n} \lvert a_i-a_j\rvert, where |x| is the absolute value of x. 

You can perform the following operation any (possibly zero) number of times: choose a traffic car and move it from its current sub-track to any other sub-track.

Find the minimum inconvenience you can achieve.

Input

The first line of input contains a single integer t (1≤ t≤ 10 000) — the number of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 2⋅ 10^5).

The second line of each test case contains n integers a_1, a_2, …, a_n (0≤ a_i≤ 10^9).

It is guaranteed that the sum of n over all test cases does not exceed 2⋅ 10^5.

Output

For each test case, print a single line containing a single integer: the minimum inconvenience you can achieve by applying the given operation any (possibly zero) number of times.

Example

Input


3
3
1 2 3
4
0 1 1 0
10
8 3 6 11 5 2 1 7 10 4


Output


0
4
21

Note

For the first test case, you can move a car from the 3-rd sub-track to the 1-st sub-track to obtain 0 inconvenience.

For the second test case, moving any car won't decrease the inconvenience of the track.
import java.io.*;
import java.util.*;

public class Codeforces {

    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        int t = 1;
        t = fs.getInt();
        while (t-- > 0) {
            int n = fs.getInt();

            long[] ar = new long[n];

            long sum = 0;
            for (int i = 0; i < n; i++) {
                ar[i] = fs.getInt();
                sum += ar[i];
            }

            long a = sum / n;
            long b = sum % n;

            for (int i = 0; i < ar.length; i++) {
                ar[i] = a;
            }

            int j = 0;
            while (b != 0) {
                ar[j % n] += 1;
                b -= 1;
                j += 1;
            }

            Utility.sort(ar);

            long ans = 0;
            for (int i = 0; i < n - 1; i++) {
                sum -= ar[i];
                ans += sum - (n - i - 1) * ar[i];
            }

            System.out.println(ans);

        }
        pw.close();
    }
}

class MOD {
    static long mod = 1000000007;

    static long add(long x, long y) {
        long result = x + y;
        return result > mod ? result - mod : result;
    }

    static long sub(long x, long y) {
        long result = x - y;
        return result < 0 ? result + mod : result;
    }

    static long mul(long x, long y) {
        long result = x * y;
        return result >= mod ? result % mod : result;
    }

    static long pow(long x, long y) {
        long result = 1;
        x %= mod;
        while (y > 0) {
            if ((y & 1) == 1)
                result = mul(result, x);
            x = mul(x, x);
            y = y >>> 1;
        }
        return result;
    }

    static long modInv(long x) {
        return pow(x, mod - 2);
    }

}

class Utility {

    static int ceil(int a, int b) {
        if (a == 0)
            return 0;
        return (a - 1) / b + 1;
    }

    static long ceil(long a, long b) {
        if (a == 0)
            return 0;
        return (a - 1) / b + 1;
    }

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

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

    static int binarySearch(int[] ar, int x, int start, int end) {
        int l = start;
        int r = end;
        while (l <= r) {
            int mid = l + (r - l) / 2;
            if (ar[mid] == x) {
                return mid;
            } else if (ar[mid] > x) {
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        return -1;
    }

    static int lowerBound(int[] ar, int x) {
        int l = 0;
        int r = ar.length - 1;
        while (l <= r) {
            int mid = l + (r - l) / 2;

            if (ar[mid] >= x)
                r = mid - 1;
            else
                l = mid + 1;
        }
        return r + 1;
    }

    static int upperBound(int[] ar, int x) {
        int l = 0;
        int r = ar.length - 1;
        while (l <= r) {
            int mid = l + (r - l) / 2;

            if (ar[mid] > x)
                r = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    static void sort(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a)
            l.add(i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++)
            a[i] = l.get(i);
    }

    static void sort(long[] a) {
        ArrayList<Long> l = new ArrayList<>();
        for (long i : a)
            l.add(i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++)
            a[i] = l.get(i);
    }

    static boolean isPalindrome(String s) {
        char[] ss = s.toCharArray();
        int i = 0;
        int j = s.length() - 1;

        while (i < j) {
            if (ss[i] != ss[j]) {
                return false;
            }
            i += 1;
            j -= 1;
        }
        return true;
    }

    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 * i <= n; i += 2) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

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

    static void printArray(long[] ar) {
        for (int i = 0; i < ar.length; i++) {
            System.out.print(ar[i] + " ");
        }
        System.out.println();
    }

    static void printIntList(List<Integer> list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + " ");
        }
        System.out.println();
    }

    static void printLongList(List<Long> list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + " ");
        }
        System.out.println();
    }

    static long chooseRecursive(long n, long k) {
        if (n < k)
            return 0;
        if (k == 0 || k == n)
            return 1;
        return chooseRecursive(n - 1, k - 1) + chooseRecursive(n - 1, k);
    }

    static long chooseOptimised(long n, long k) {
        long res = 1;
        if (k > n - k)
            k = n - k;
        for (long i = 0; i < k; i++) {
            res *= (n - i);
            res /= (i + 1);
        }
        return res;
    }

    static List<Integer> divisors(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i * i < n; i++) {
            if (n % i == 0)
                list.add(i);
        }
        for (int i = (int) Math.sqrt(n); i >= 1; i--) {
            if (n % i == 0)
                list.add(n / i);
        }
        return list;
    }

}

class Pair implements Comparable<Pair> {
    Integer first;
    Integer second;

    Pair(Integer f, Integer s) {
        this.first = f;
        this.second = s;
    }

    public String toString() {
        return "(" + this.first + ", " + this.second + ")";
    }

    @Override
    public boolean equals(Object object) {
        if (((Pair) object).first == this.first && ((Pair) object).second == this.second && object instanceof Pair) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (String.valueOf(first) + ":" + String.valueOf(second)).hashCode();
    }

    @Override
    public int compareTo(Pair p) {
        int f = first.compareTo(p.first);
        if (f != 0)
            return f;

        return Integer.compare(second, p.second);
    }
}

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 getInt() {
        return Integer.parseInt(next());
    }

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

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

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

    List<Integer> getIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++)
            list.add(getInt());
        return list;
    }

    List<Long> getLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++)
            list.add(getLong());
        return list;
    }
}
