**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
#include <cstdio>
#include <algorithm>
using namespace std;

int t;
int n;
int a[300005];
int b[300006];
int chk(int k){
	int i,res=0,c;
	for(i=1;i<=n;i++) a[i]=b[i];
	a[1]-=k*2;
	a[2]+=k;
	res+=k;
	for(i=2;i<n;i++){
		if((a[i]-a[1])%2==1||a[i]<a[1]) return -1;
		else{
			c=(a[i]-a[1])/2;
			a[i]=a[1];
			a[i+1]+=c;
			res+=c;
		}
	}
	if(a[n]==a[1]) return res;
	else return -1;
}
int slv(){
	int l,r,mid,res,cnt;
	res=cnt=-1;
	l=0;
	r=(b[n]-b[1])/2;
	while(l<=r){
		mid=l+r>>1;
		cnt=chk(mid);
		if(cnt!=-1){
			res=cnt;
			r=mid-1;
		}else l=mid+1;
	}
	return res;
}

int main(){
	int i,j,r1,r2;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		j=1;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
			if(i!=1&&a[i]<=a[j]) j=i;
		}
		j=j%n+1;
		for(i=1,j;i<=n;i++,j=j%n+1) b[i]=a[j];
		r1=slv();
		b[1]++;
		b[n]-=2;
		r2=slv();
		if(r2!=-1) r2++;
		if(r1==-1&&r2==-1) puts("-1");
		else if(r1==-1) printf("%d\n",r2);
		else if(r2==-1) printf("%d\n",r1);
		else printf("%d\n",min(r1,r2));
	}
	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
1 1
3
1 3 2
4
2 1 2 6
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
#include <iostream>
using namespace std;

long long test, n, cnt, a[200010], tmp;
pair<long long,long long> maxx;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> test;
	while (test--) {
		cin >> n;
		cnt = 0;
		for (int i = 0; i < n; i++) cin >> a[i];
		maxx = {0,0};
		for (int i = 0; i < n; i++) maxx = max(maxx,{a[i],i});
		for (int i = 1; i <= 40; i++) {
			for (int j = 0; j < n; j++) {
				int ii = (maxx.second+j)%n;
				if (a[ii] < 2) continue;
				tmp = max(0LL,max((a[ii]-a[(ii+1)%n]+2)/3,(a[ii]-a[(ii-1+n)%n]+1)/2));
				cnt += tmp;
				a[ii] -= tmp*2;
				a[(ii+1)%n] += tmp;
			}
		}
		for (int i = 1; i < n; i++) {
			if (a[i] != a[i-1]) {
				cout << -1 << endl;
				goto skip;
			}
		}
		cout << cnt << endl;
		skip:;
	}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given buggy code, we need to consider the following aspects:

1. **Array Length and Values**: The array should be of a length that can be processed within the constraints, but it should be complex enough to expose the bug.
2. **Initial Values**: The initial values should be such that the algorithm has to perform multiple operations to make the array equal, and it should be possible to make the array equal.
3. **Edge Cases**: Consider edge cases where the array has values that are close to each other but not equal, or where the operations need to be performed multiple times to balance the array.

Let's create a test case that meets these criteria:

- **Test Case 1**: A small array where the values are close but not equal, and the operations need to be performed multiple times to balance the array.
- **Test Case 2**: An array where the values are such that the operations will not be able to make the array equal, and the output should be -1.
- **Test Case 3**: A larger array that is more complex and requires multiple operations to balance.

Here is the test input:

```plaintext
3
3
1 3 2
4
2 1 2 6
5
1 2 3 4 5
```

### Explanation:
1. **Test Case 1**:
   - Array: `[1, 3, 2]`
   - This array is small and the values are close but not equal. The operations need to be performed to balance the array.
   - Expected Output: `-1` (It is impossible to make all elements equal in this case.)

2. **Test Case 2**:
   - Array: `[2, 1, 2, 6]`
   - This array is slightly larger and the values are more spread out. The operations need to be performed to balance the array.
   - Expected Output: `3` (It is possible to make all elements equal with 3 operations.)

3. **Test Case 3**:
   - Array: `[1, 2, 3, 4, 5]`
   - This array is larger and the values are in a sequence. The operations need to be performed to balance the array.
   - Expected Output: `-1` (It is impossible to make all elements equal in this case.)

This test input should help expose the bug in the given buggy code by covering both possible and impossible scenarios.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
def check(L,num,id,n):
    M = [x for x in L]
    for i in range(id,id+2*n):
        id1 = (i%n)
        id2 = (i+1)%n
        x1 = M[i%n]
        x2 = M[(i+1)%n]
        a = x1-num
        if(a%2 == 0):
            M[id1] = num
            M[id2] += a//2
        else:
            if(num > 0):
                M[id1] = num-1
                M[id2] += a//2 + 1
            else:
                return False
        # print(M,id,num,id1)
    if(len(set(M)) == 1):
        return True
    return False

for _ in range(int(input())):
    n = int(input())
    L = list(map(int,input().split()))
    s = sum(L)
    m = max(L)
    id =L.index(m)
    l = 0
    r = s//n
    if(len(set(L)) == 1):
        print(0)
        continue
    f = 0
    ans1 = -1
    while(l < r):
        # print(l,r)
        mid = (l+r)//2
        if(mid == l):break
        if(check(L,mid,id,n)):
            f = 1
            ans1 = mid
            l = mid+1
        else:
            r = mid
    if(check(L,l,id,n)):
        f = 1
        ans1 = l
    if(check(L,r,id,n)):
        f = 1
        ans1 = r
    if(f):
        ans = sum(L)-ans1*n
        print(ans)
    else:
        print(-1)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
2 2
3
1 3 5
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import math

def check(a, eq, idx_max):
    a = list(a)
    cnt = q = 0
    i = idx_max

    while q < len(a):
        if i == len(a): i = 0
        if a[i] <= eq:
            q += 1; continue
        op = (a[i] - eq) // 2
        if (a[i] - eq) % 2 > 0: op += 1
        cnt += op
        if i + 1 < len(a):
            a[i] -= 2 * op; a[i + 1] += op
        else:
            a[i] -= 2 * op; a[0] += op
        i += 1

    if len(set(a)) == 1:
        return len(a), cnt

    cnt_eq = 0; flag = 0
    for i in range(len(a)):
        cnt_eq += 1 if a[i] == eq else 0
        if a[i] < 0: flag = 1

    if flag: cnt_eq = 0
    return cnt_eq, cnt

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    max_ = max(a); idx_max = a.index(max_)
    if len(set(a)) == 1:
        print(0)
        return

    l = 0; r = max_
    ans = math.inf
    while l <= r:
        mid = (l + r) // 2
        cnt_eq, cnt_op = check(a, mid, idx_max)
        if cnt_eq < len(a):
            r = mid - 1
        else:
            l = mid + 1
            ans = min(cnt_op, ans)

    if ans == math.inf:
        print(-1)
        return

    print(ans)

for _ in range(int(input())):
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
1 2
3
1 2 3
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import math

def check(a, eq, idx_max):
    a = list(a); sum_ = sum(a)
    cnt = 0; i = idx_max

    _5n = len(a) * 3; cnt_step = 0
    while sum_ > eq * len(a):
        cnt_step += 1
        if cnt_step >= _5n: break

        if i == len(a): i = 0
        if a[i] <= eq: continue

        op = (a[i] - eq) // 2
        if (a[i] - eq) % 2 > 0: op += 1
        cnt += op

        a[i] -= 2 * op; sum_ -= 2 * op; sum_ += op
        if i + 1 < len(a): a[i + 1] += op
        else: a[0] += op

        i += 1

    cnt_eq = 0
    for i in range(len(a)):
        cnt_eq += 1 if a[i] == eq else 0

    return cnt_eq, cnt

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    max_ = max(a); idx_max = a.index(max_)
    if len(set(a)) == 1:
        print(0)
        return

    l = 0; r = max_
    ans = math.inf
    while l <= r:
        mid = (l + r) // 2
        cnt_eq, cnt_op = check(a, mid, idx_max)
        if cnt_eq < len(a):
            r = mid - 1
        else:
            l = mid + 1
            ans = min(cnt_op, ans)

    if ans == math.inf:
        print(-1)
        return

    print(ans)

for _ in range(int(input())):
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
1 3
3
1 2 3
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import java.io.*;
import java.util.*;
import java.lang.*;
import java.util.function.LongConsumer;

public class CP
{
    static long mod = (long)(1e9+7);
    static int minInt = Integer.MIN_VALUE;
    static int maxInt = Integer.MAX_VALUE;
    static long minLong = Long.MIN_VALUE;
    static long maxLong = Long.MAX_VALUE;

    /*-----------------------------------------------------------------------MAIN CODE HERE----------------------------------------------------------------------------*/
    static void time_is_running(PrintWriter out,FastReader sc) throws IOException
    {
        int n = sc.ni(),arr[] = new int[n];
        for(int j=0;j<n;j++) arr[j] = sc.ni();

        int s=0,e=(int)1e9,ans=maxInt;
        while(s<=e){
            int mid = s+((e-s)/2);

            int tmp = check(arr,mid);
            if(tmp==-1){
                e=mid-1;
            }
            else{
                ans=Math.min(ans,tmp);
                s=mid+1;
            }
        }
        ans=ans==maxInt?-1:ans;

        out.println(ans);
    }

    static int check(int a[],int k){
        int maxInd=0;
        int arr[] = Arrays.copyOf(a,a.length);
        for(int j=0;j<arr.length;j++){
            if(arr[maxInd]<arr[j]) maxInd=j;
        }

        if(arr[maxInd]<k) return -1;
        int totalOps=0;
        for(int j=0;j<arr.length;j++){
            int ind = (j+maxInd)%arr.length;
            if(arr[ind]<=k){
                totalOps+=(k-arr[ind]);
                arr[(ind-1+arr.length)%arr.length]-=(2*(k-arr[ind]));
                arr[ind]=k;
            }
            else{
                int ops = (arr[ind]-k+1)/2;
                totalOps+=ops;
                arr[ind]-=(2*ops);
                arr[(ind+1)%arr.length]+=ops;
            }
        }

        for(int e:arr){
            if(e!=k) return -1;
        }

        return totalOps;
    }
    /*----------------------------------------------------------------------------END---------------------------------------------------------------------------------*/

    public static void main(String[] args) throws IOException
    {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader sc = new FastReader();
        int n = sc.ni();
        for(int i=1;i<=n;i++)
            time_is_running(out,sc);
        out.close();
    }

    /*-----------------------------------------------------------------------SKIP THIS PART----------------------------------------------------------------------------*/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
//        public FastReader() throws FileNotFoundException {
//            br = new BufferedReader(new FileReader("input.txt"));
//        }
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int ni() {return Integer.parseInt(next());}
        long nl() {return Long.parseLong(next());}
        double nd() {return Double.parseDouble(next());}
        char nextChar(){return next().charAt(0);}
        String nextLine() {
            String str = "";
            try {
                if (st.hasMoreTokens()) {
                    str = st.nextToken("\n");
                } else {
                    str = br.readLine();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    /*-------------------------------------------------------------------------END------------------------------------------------------------------------------*/
}
class Pair
{
    int a,b,c;
    Pair(int a1,int b1,int c1)
    {
        this.a=a1;
        this.b=b1;
        this.c=c1;
    }
}
class Pair2
{
    long a,b;
    Pair2(long a1,long b1)
    {
        this.a=a1;
        this.b=b1;
    }
}
class comparingLong implements Comparator<Pair2>{
    public int compare(Pair2 s1, Pair2 s2){
        // We are returning the object in asending order
        if (s1.a < s2.a)
            return -1;
        else if (s1.a > s2.a)
            return 1;
        return 0;
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to consider edge cases and scenarios that are likely to cause the code to fail. Here are the steps to think through this:

1. **Check for Infeasibility**: The code should return `-1` if it is impossible to make all elements of the array equal. This can happen if the sum of the array elements is not divisible by the number of elements (i.e., `sum(a) % n != 0`).

2. **Check for Minimum Operations**: The code should correctly calculate the minimum number of operations needed. This can be tricky if the array has large values or if the operations need to be carefully balanced.

3. **Check for Edge Cases**: Small arrays and arrays with specific patterns (like all elements being the same, or elements that are already close to the target value) can help in testing.

Given these considerations, let's create a small-scale test input that is likely to expose the bug:

```plaintext
3
3
1 2 3
4
1 2 3 4
5
1 2 3 4 5
```

Explanation:
- **Test Case 1**: `n = 3`, `a = [1, 2, 3]`
  - The sum of the array is `6`, which is divisible by `3`.
  - The target value for each element is `2` (since `6 / 3 = 2`).
  - The code should be able to make all elements equal to `2` with a minimum number of operations.

- **Test Case 2**: `n = 4`, `a = [1, 2, 3, 4]`
  - The sum of the array is `10`, which is not divisible by `4`.
  - The code should return `-1` because it is impossible to make all elements equal.

- **Test Case 3**: `n = 5`, `a = [1, 2, 3, 4, 5]`
  - The sum of the array is `15`, which is divisible by `5`.
  - The target value for each element is `3` (since `15 / 5 = 3`).
  - The code should be able to make all elements equal to `3` with a minimum number of operations.

This test input covers both feasible and infeasible cases, and it is small enough to be manageable and directly output.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        int t, n, carry, k, tmp;
        long sum;
        boolean canBe;
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[2*100000];
        t = sc.nextInt();
        while (t-- != 0) {
            n = sc.nextInt();
            sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                sum += arr[i];
            }
            carry = 0;
            for (int i = 0; i < n; i++) {
                tmp = (carry+arr[i])%2;
                carry = (carry + arr[i])/2;
                arr[i] = tmp;
            }
            k = 0;
            while (carry != 0) {
                tmp = (carry + arr[k])%2;
                carry = (carry + arr[k])/2;
                arr[k] = tmp;
                k = (k+1)%n;
            }
            canBe = true;
            for (int i = 1; i < n; i++) {
                if (arr[i] != arr[i-1]) {
                    System.out.println(-1);
                    canBe = false;
                    break;
                }
            }
            if (canBe) {
                System.out.println(sum%n);
            }
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3
1 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
#include<bits/stdc++.h>
using namespace std;
//#define map unordered_map
#define re register
#define ll long long
#define cll const ll
#define forl(i,a,b) for(re ll (i)=(a);i<=(b);(i)++)
#define forr(i,a,b) for(re ll (i)=(a);i>=(b);(i)--)
#define forll(i,a,b,c) for(re ll (i)=(a);i<=(b);(i)+=(c))
#define forrr(i,a,b,c) for(re ll (i)=(a);i>=(b);(i)-=(c))
#define forL(i,a,b,c) for(re ll (i)=(a);((i)<=(b)) && (c);(i)++)
#define forR(i,a,b,c) for(re ll (i)=(a);((i)>=(b)) && (c);(i)--)
#define forLL(i,a,b,c,d) for(re ll (i)=(a);((i)<=(b)) && (d);(i)+=(c))
#define forRR(i,a,b,c,d) for(re ll (i)=(a);((i)>=(b)) && (d);(i)-=(c))
#define pii pair<ll,ll>
#define mid ((l+r)>>1)
#define lowbit(x) (x&-x)
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
ll _t_;
void _clear(){}
ll n;
ll a[1000010];
ll L,R;
ll b[1000010];
ll nxt(ll x)
{
    if(x==n)
        return 1;
    return x+1;
}
ll check(ll Mid)
{
    ll sum=0;
    forl(i,1,n)
        b[i]=a[i];
    forl(_,1,(n<=30)?30:1)
        forl(i,1,n)
            if(b[i]>Mid)
            {
                ll need=(b[i]-Mid+1)/2;
                sum+=need;
                b[i]-=need*2;
                b[nxt(i)]+=need;
            }
    forl(i,1,n)
        if(b[1]!=b[i] || b[i]<0)
            return 1e18;
    return sum;
}
void solve()
{
    _clear();
    cin>>n;
    forl(i,1,n)
        cin>>a[i];
    L=0,R=2e9;
    while(L<R)
    {
        ll Mid=(L+R+1)/2;
        if(check(Mid)!=1e18)
            L=Mid;
        else
            R=Mid-1;
    }
    if(check(L)!=1e18)
        cout<<check(L)<<endl;
    else
        cout<<-1<<endl;
}
int main()
{
//    freopen("tst.txt","r",stdin);
//    freopen("sans.txt","w",stdout);
    IOS;
    _t_=1;
    cin>>_t_;
    while(_t_--)
        solve();
    QwQ;
}
/*
1
2
99999999 100000002
*/

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the provided buggy code, let's consider the following aspects:

1. **Edge Cases**:
   - **Small Array**: Test with the smallest possible array size.
   - **Large Array**: Test with an array size close to the upper limit.
   - **Uniform Array**: Test with an array where all elements are the same.
   - **Non-Uniform Array**: Test with an array where elements are not the same and require operations to make them equal.
   - **Array with Large Values**: Test with large values in the array to check the handling of large numbers.

2. **Specific Scenarios**:
   - **Impossibility**: Test with an array that cannot be made equal.
   - **Boundary Values**: Test with values close to the boundaries of the input constraints.

3. **Combination of Scenarios**:
   - Test with a combination of the above scenarios to ensure the code handles multiple edge cases.

Given these considerations, let's create a small-scale test input that is complete and valid:

```plaintext
3
2
1 1
3
1 3 2
4
2 1 2 6
```

This test input includes:
- A case where the array is already equal (no operations needed).
- A case where it is impossible to make the array equal.
- A case where operations are needed to make the array equal.

These scenarios should help expose any bugs in the buggy code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5+10;

int n;
int a[N];
int b[N];
int check(int x) {
	for(int i = 1;i <= n;i++) b[i] = a[i];
	int sum = 0;
	for(int i = 1;i <= n;i++) {
		int rd = b[i]-x;
		if(rd <= 0) continue;
		else {
			if(rd%2 == 1) rd++;
			rd /= 2;
			b[i] -= 2*rd;
			b[i%n+1] += rd;
			sum += rd;
		}
	}
	for(int i = 1;i <= n;i++) {
		int rd = b[i]-x;
		if(rd <= 0) continue;
		else {
			if(rd%2 == 1) rd++;
			rd /= 2;
			b[i] -= 2*rd;
			b[i%n+1] += rd;
			sum += rd;
		}
	}
	if(b[1] > x) return -1;
	int tmp = x-b[1];
	sum += n*tmp;
	for(int i = 1;i <= n;i++) if(b[i]-tmp != x) return -1;
	return sum;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while(T--) {
		cin >> n;
		int maxn = 0;
		for(int i = 1;i <= n;i++) cin >> a[i], maxn = max(maxn, a[i]);
		int l = 0, r = maxn+1, ans = -1;
		while(l <= r) {
			int mid = (l+r)/2;
			int x = check(mid);
			if(x < 0) r = mid-1;
			else ans = x, l = mid+1;
		}
		cout << ans << '\n';
	}
	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
1 2
3
1 2 3
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
"""
Let  m be the final equal value.
Let x_i be the number of times we subtract 2 from a_i.
We have the following equation:
a_0 - 2x_0 + x_{n-1} = m
a_1 - 2x_1 + x_0 = m
a_2 - 2x_2 + x_1 = m
...
a_{n-1} - 2x_{n-1} + x_{n-2} = m

Def: We say m is feasible if the above system has a solution x where each x_i is non-negative integer.
Furthermore, the total number of operations is sum(x). From the above, sum(x) = sum(a) - n*m.
Thus, we minimize sum(x) by maximizing m such that m is feasible.
Note that if m is feasible then m+1 is feasible by adding to each x_i.
Hence, we can do binary search on m if we can tell whether m is feasible or not.

Once we fix m, since we have n linear equations and n variables,
We can solve for each x_i which has the following form (exercise):
Let y_i = a_i - m, then
x_i = (2^{n-1} y_i + 2^{n-2} y_{i-1 % n} + a^{n-3} y_{i-2 % n} + ... + 2^0 y_{i-(n-1) % n} - m) / (2^n - 1)
If all x_i are non-negative integers, then m is feasible.
"""

def is_feasible(a, m):
    n = len(a)
    x = [0] * n
    y = [a[i] - m for i in range(n)]
    for i in range(n):
        for j in range(n):
            x[i] += (2 ** (n - 1 - j)) * y[(i - j) % n]
        x[i] = x[i] / (2 ** n - 1)
        if not(x[i].is_integer()) or (x[i] < 0):
            return False, x

    return True, x

if __name__ == '__main__':
    num_tests = int(input())
    for i in range(num_tests):
        n = int(input())
        a = list(map(int, input().split()))

        l, r = 0, max(a)
        ans = -1
        while l <= r:
            m = (l + r) // 2
            feasible, x = is_feasible(a, m)
            if feasible:
                ans = sum(x)
                l = m + 1
            else:
                r = m - 1
        print(int(ans))

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3
1 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    mn = min(a)
    for i in range(0, n):
        if a[i] == mn:
            if i != n - 1:
                a = a[i + 1: ] + a[: i + 1]
            break
    t = 0
    for i in range(0, n):
        t += (a[i] << i)
    if t % ((1 << n) - 1):
        print("-1")
        continue
    S = t // ((1 << n) - 1)
    print(sum(a) - S * n)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
2 2
3
3 1 1
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import java.io.*;
import java.util.*;

public class Main {
    public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353;
    public static void main(String args[]){
        try {
            PrintWriter o = new PrintWriter(System.out);
            boolean multiTest = true;
            // init
            if(multiTest) {
                int t = nextInt(), loop = 0;
                while (loop < t) {loop++;solve(o);}
            } else solve(o);
            o.close();
        } catch (Exception e) {e.printStackTrace();}
    }
    static int n;
    static long sum, record;
    static int[] a;
    static void solve(PrintWriter o) {
        try {
            n = nextInt();
            a = new int[n];
            sum = 0l;
            record = 0l;
            for(int i=0;i<n;i++) {
                a[i] = nextInt(); // 1e9
                sum += a[i];
            }
            int l = 0, r = (int)1e9+1;
            while(l < r) {
                int m = (l+r)>>1;
                if(check(m)) l = m+1;
                else r = m;
            }
            if(l == 0) {
                o.println(-1);
                return;
            }
            l--;
            check(l);
            o.println(record);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    static boolean check(int m) {
        int[] b = a.clone();
        long remain = sum-1l*m*n, use = 0l;
        if(remain < 0) return false;
        for(int i=0;i<3*n;i++) {
            long d = b[i%n]-m;
            if(d > 0) {
                long t = d/2;
                int md = (int)(d%2);
                use += t;
                b[i%n] = m+md;
                b[(i+1)%n] += t;
            }
            if(use > remain) {
                return false;
            }
        }
        for(int i=0;i<n-1;i++) if(b[i] != b[i+1]) return false;
        use += 1l*(b[0]-m)*n;
        record = use;
        return use <= remain;
    }
    public static int upper_bound(long[] preSum, long val){
        int l = 0, r = preSum.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(preSum[mid] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(List<long[]> li, long val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid)[0] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(List<Integer> li, int val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid) <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(int[] a, int val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(List<Integer> li, int val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid) < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(int[] a, int val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a%b);
    }
    public static long[] extgcd(long a, long b) {
        if(b == 0) return new long[]{1, 0};
        long[] it = extgcd(b, a%b);
        long x = it[1], y = it[0];
        y -= a/b*x;
        return new long[]{x, y};
    }
    public static long lcm(long a, long b){
        return a / gcd(a,b)*b;
    }
    public static long qpow(long a, long n, int md){
        a %= md;
        long ret = 1l;
        while(n > 0){
            if((n & 1) == 1) ret = ret * a % md;
            n >>= 1;
            a = a * a % md;
        }
        return ret;
    }
    public static class FenWick {
        int n;
        long[] a;
        long[] tree;
        public FenWick(int n){
            this.n = n;
            a = new long[n+1];
            tree = new long[n+1];
        }
        private void add(int x, long val){
            while(x <= n){
                tree[x] += val;
                x += x&-x;
            }
        }
        private void addMx(int x, long val) {
            a[x] += val;
            tree[x] = a[x];
            while(x <= n) {
                for(int i=1;i<(x&-x);i<<=1) tree[x] = Math.max(tree[x], tree[x-i]);
                x += x&-x;
            }
        }
        private long query(int x){
            long ret = 0l;
            while(x > 0){
                ret += tree[x];
                x -= x&-x;
            }
            return ret;
        }
        private long queryMx(int l, int r) {
            long res = 0l;
            while(l <= r) {
                if(r-(r&-r) >= l) {
                    res = Math.max(res, tree[r]);
                    r -= r&-r;
                }
                else {
                    res = Math.max(res, a[r]);
                    r--;
                }
            }
            return res;
        }
    }
    static class Pair {
        Integer p1, p2;
        public Pair(Integer p1, Integer p2) {
            this.p1 = p1;
            this.p2 = p2;
        }
        @Override
        public int hashCode() {
            int prime = 31, ret = 0;
            ret = ret*prime+p1.hashCode();
            ret = ret*prime+p2.hashCode();
            return ret;
        }
        @Override
        public boolean equals(Object o) {
            if(o instanceof Pair pair) {
                return p1.equals(pair.p1) && p2.equals(pair.p2);
            }
            return false;
        }
    }
    static class DSU {
        int[] parent;
        int[] size;
        public DSU(int n) {
            parent = new int[n];
            size = new int[n];
            for(int i=0;i<n;i++) {
                parent[i] = i;
                size[i] = 1;
            }
        }
        public int find(int x) {
            if(parent[x] != x) parent[x] = find(parent[x]);
            return parent[x];
        }
        public void union(int x, int y) {
            int root_x = find(x);
            int root_y = find(y);
            if(root_x == root_y) return;
            parent[root_x] = root_y;
            size[root_y] += size[root_x];
            size[root_x] = 0;
        }
    }
    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer tokenizer = new StringTokenizer("");
    private static String next() throws IOException{
        while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine());}
        return tokenizer.nextToken();
    }
    public static int nextInt() throws IOException {return Integer.parseInt(next());}
    public static Long nextLong() throws IOException {return Long.parseLong(next());}
    public static double nextDouble() throws IOException {return Double.parseDouble(next());}
    public static char nextChar() throws IOException {return next().toCharArray()[0];}
    public static String nextString() throws IOException {return next();}
    public static String nextLine() throws IOException {return reader.readLine();}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3
1 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import java.io.*;
import java.util.*;

public class Main {
    public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353;
    public static void main(String args[]){
        try {
            PrintWriter o = new PrintWriter(System.out);
            boolean multiTest = true;
            // init
            if(multiTest) {
                int t = nextInt(), loop = 0;
                while (loop < t) {loop++;solve(o);}
            } else solve(o);
            o.close();
        } catch (Exception e) {e.printStackTrace();}
    }
    static int n;
    static long sum;
    static int[] a;
    static void solve(PrintWriter o) {
        try {
            n = nextInt();
            a = new int[n];
            sum = 0l;
            for(int i=0;i<n;i++) {
                a[i] = nextInt(); // 1e9
                sum += a[i];
            }
            int l = 0, r = (int)1e9+1;
            while(l < r) {
                int m = (l+r)>>1;
                if(check(m)) l = m+1;
                else r = m;
            }
            if(l == 0) {
                o.println(-1);
                return;
            }
            l--;
            o.println(sum-1l*l*n);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    static boolean check(int m) {
        int[] b = a.clone();
        if(sum < 1l*n*m) return false;
        long tot = sum;
        for(int i=0;;i++) {
            long d = b[i%n]-m;
            if(d > 0) {
                long t = (d+1)/2;
                int md = (int)d%2;
                if(md > 0) b[i%n] = m-1;
                else b[i%n] = m;
                b[(i+1)%n] += t;
                tot -= t;
            }
            if(tot <= 1l*n*m) break;
        }
        for(int i=0;i<n-1;i++) if(b[i] != b[i+1]) return false;
        return true;
    }
    public static int upper_bound(long[] preSum, long val){
        int l = 0, r = preSum.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(preSum[mid] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(List<long[]> li, long val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid)[0] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(List<Integer> li, int val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid) <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(int[] a, int val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(List<Integer> li, int val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid) < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(int[] a, int val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a%b);
    }
    public static long[] extgcd(long a, long b) {
        if(b == 0) return new long[]{1, 0};
        long[] it = extgcd(b, a%b);
        long x = it[1], y = it[0];
        y -= a/b*x;
        return new long[]{x, y};
    }
    public static long lcm(long a, long b){
        return a / gcd(a,b)*b;
    }
    public static long qpow(long a, long n, int md){
        a %= md;
        long ret = 1l;
        while(n > 0){
            if((n & 1) == 1) ret = ret * a % md;
            n >>= 1;
            a = a * a % md;
        }
        return ret;
    }
    public static class FenWick {
        int n;
        long[] a;
        long[] tree;
        public FenWick(int n){
            this.n = n;
            a = new long[n+1];
            tree = new long[n+1];
        }
        private void add(int x, long val){
            while(x <= n){
                tree[x] += val;
                x += x&-x;
            }
        }
        private void addMx(int x, long val) {
            a[x] += val;
            tree[x] = a[x];
            while(x <= n) {
                for(int i=1;i<(x&-x);i<<=1) tree[x] = Math.max(tree[x], tree[x-i]);
                x += x&-x;
            }
        }
        private long query(int x){
            long ret = 0l;
            while(x > 0){
                ret += tree[x];
                x -= x&-x;
            }
            return ret;
        }
        private long queryMx(int l, int r) {
            long res = 0l;
            while(l <= r) {
                if(r-(r&-r) >= l) {
                    res = Math.max(res, tree[r]);
                    r -= r&-r;
                }
                else {
                    res = Math.max(res, a[r]);
                    r--;
                }
            }
            return res;
        }
    }
    static class Pair {
        Integer p1, p2;
        public Pair(Integer p1, Integer p2) {
            this.p1 = p1;
            this.p2 = p2;
        }
        @Override
        public int hashCode() {
            int prime = 31, ret = 0;
            ret = ret*prime+p1.hashCode();
            ret = ret*prime+p2.hashCode();
            return ret;
        }
        @Override
        public boolean equals(Object o) {
            if(o instanceof Pair pair) {
                return p1.equals(pair.p1) && p2.equals(pair.p2);
            }
            return false;
        }
    }
    static class DSU {
        int[] parent;
        int[] size;
        public DSU(int n) {
            parent = new int[n];
            size = new int[n];
            for(int i=0;i<n;i++) {
                parent[i] = i;
                size[i] = 1;
            }
        }
        public int find(int x) {
            if(parent[x] != x) parent[x] = find(parent[x]);
            return parent[x];
        }
        public void union(int x, int y) {
            int root_x = find(x);
            int root_y = find(y);
            if(root_x == root_y) return;
            parent[root_x] = root_y;
            size[root_y] += size[root_x];
            size[root_x] = 0;
        }
    }
    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer tokenizer = new StringTokenizer("");
    private static String next() throws IOException{
        while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine());}
        return tokenizer.nextToken();
    }
    public static int nextInt() throws IOException {return Integer.parseInt(next());}
    public static Long nextLong() throws IOException {return Long.parseLong(next());}
    public static double nextDouble() throws IOException {return Double.parseDouble(next());}
    public static char nextChar() throws IOException {return next().toCharArray()[0];}
    public static String nextString() throws IOException {return next();}
    public static String nextLine() throws IOException {return reader.readLine();}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given code, let's consider the following points:

1. **Sum of Elements**: The sum of the elements in the array should be divisible by the number of elements (n) to make all elements equal. If not, it's impossible to achieve the goal.

2. **Operation Constraints**: The operation `decrease a_i by 2 and increase a_{(i \bmod n) + 1} by 1` should be considered. This operation can only change the elements in a specific way, and the code might not handle certain edge cases correctly.

3. **Edge Cases**:
   - **Small n**: Small values of n (e.g., 2 or 3) can help in testing the algorithm's behavior with minimal elements.
   - **Large Elements**: Large values of elements (up to 1e9) can test the algorithm's handling of large numbers.
   - **Uneven Distribution**: Elements that are not uniformly distributed can test the algorithm's ability to handle imbalances.

4. **Impossibility Case**: A test case where the sum of elements is not divisible by n should result in -1.

5. **Boundary Conditions**: Test cases where the elements are already equal or close to being equal can help verify the algorithm's efficiency.

Given these points, let's create a test input that maximizes the failure probability:

```plaintext
3
3
1 2 3
4
1 1 1 1
5
10 20 30 40 50
```

Explanation:
1. **Test Case 1**: `n = 3`, `a = [1, 2, 3]`
   - Sum = 6, which is divisible by 3.
   - The elements are not equal, so the algorithm should perform operations to make them equal.

2. **Test Case 2**: `n = 4`, `a = [1, 1, 1, 1]`
   - Sum = 4, which is divisible by 4.
   - The elements are already equal, so the algorithm should return 0 operations.

3. **Test Case 3**: `n = 5`, `a = [10, 20, 30, 40, 50]`
   - Sum = 150, which is divisible by 5.
   - The elements are not equal, so the algorithm should perform operations to make them equal. This case is more challenging due to the larger values and the need to balance the array.

This test input should help expose any bugs in the given code, especially in handling the sum and the operations to make the elements equal.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
using PII = pair<int, int>;
const int N = 2e5 + 10;
int a[N], b[N];
int n;
bool check(int x)
{
    for (int i = 1; i <= n; i++)
    {
        b[i] = a[i] - x;
        cerr << b[i] << ' ';
    }
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int i = 1; i <= n; i++)
        {
            if (b[i] > 0)
            {
                flag = true;
                int nxt = (i % n) + 1;
                b[nxt] += (b[i] + 1) / 2;
                b[i] -= (b[i] + 1) / 2 * 2;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (b[i])
            return false;
    }
    return true;
}
void solve()
{
    int sums = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sums += a[i];
    }
    int l = 1, r = *max_element(a + 1, a + 1 + n), ans = -1, cnt = 0;
    while (l <= r)
    {
        cnt++;
        int mid = l + r >> 1;
        cerr << mid << endl;
        if (check(mid))
        {
            ans = mid;
            l = mid + 1;
        }
        else
            r = mid - 1;
        if (cnt > 3)
            break;
    }
    if (ans == -1)
        cout << ans << endl;
    else
        cout << sums - ans * n << endl;
}

signed main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given code, we need to consider the following aspects:

1. **Edge Cases**: Test cases where the array has specific properties that might cause the algorithm to fail.
2. **Boundary Conditions**: Test cases with the minimum and maximum possible values for `n` and `a[i]`.
3. **Special Patterns**: Test cases with specific patterns in the array that might cause the algorithm to behave incorrectly.

Let's analyze the code to identify potential issues:

- The `check` function uses a binary search approach to find the minimum value that all elements can be reduced to.
- The `check` function iterates over the array and attempts to balance the elements by moving values from one index to the next.
- The code uses a binary search to find the minimum value `x` such that all elements can be reduced to `x`.

### Potential Issues:
1. **Infinite Loop**: The `while (flag)` loop in the `check` function might run indefinitely if the array is not balanced correctly.
2. **Incorrect Binary Search**: The binary search might not converge to the correct value if the array is not properly balanced.
3. **Edge Cases**: Arrays with specific patterns might cause the binary search to fail.

### Challenging Test Input:
To expose these issues, let's create a test case where the array has a specific pattern that might cause the binary search to fail or the balancing to go wrong.

```plaintext
1
3
1 2 3
```

### Explanation:
- **Test Case**: `n = 3` and `a = [1, 2, 3]`.
- **Expected Output**: `-1` because it is impossible to make all elements equal using the given operations.

### Reasoning:
- The sum of the array is `1 + 2 + 3 = 6`.
- To make all elements equal, the sum must be divisible by `n`, which it is in this case (`6 % 3 == 0`).
- However, the operations provided (decrease by 2 and increase the next element by 1) cannot balance the array to have all elements equal. The minimum value that can be achieved is 1, but the maximum value is 3, and the operations cannot reduce the maximum value to the minimum value.

This test case should expose the bug in the code by showing that the algorithm fails to correctly determine that it is impossible to make all elements equal.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
#include <bits/stdc++.h>
using namespace std;

#define int long long

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int mx = -1e9, ix = 0;
    for (int i = 0; i < n; i++)
        if (a[i] > mx) mx = a[i], ix = i;

    if (ix != 0) rotate(a.begin(), a.begin() + ix, a.end());

    int ans = 0;
    int times = 300*n, i = 0;
    while (times--) {
        int c = (a[i] - a[(i+1)%n] + 2)/3;
        c = max(c, 0LL);
        a[i] -= 2*c; a[(i+1)%n] += c;
        if (a[i] < 0) break;
        ans += c;
        i = rand()%n;
    }

    for (int i = 0; i < n; i++)
        if (a[i] < 0 or a[i] != a[0]) {
            cout << -1 << "\n";
            return;
        }

    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    srand(time(NULL));

    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif

    int tt; cin >> tt;
    while (tt--)
        solve();

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
1 3
3
2 2 2
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
import sys

def input():
    return sys.stdin.readline().strip()

def getints():
    return map(int, sys.stdin.readline().strip().split())

def con(num, l):
    l = list(l)
    ans = 0
    for i in range(len(l)):
        if l[i] > num:
            t = l[i] - num
            if t % 2 != 0:
                t += 1
            l[i] -= t
            l[(i + 1) % len(l)] += t // 2
            ans += t // 2
    for i in range(len(l)):
        if l[i] > num:
            t = l[i] - num
            if t % 2 != 0:
                t += 1
            l[i] -= t
            l[(i + 1) % len(l)] += t // 2
            ans += t // 2
    for i in range(len(l) - 1, -1, -1):
        if l[i] <= num:
            l[i - 1] -= 2 * (num - l[i])
            ans += (num - l[i])
            l[i] = num
    if l[-1] == num:
        return True, ans
    else:
        return False, -1

for _ in range(int(input())):
    n = int(input())
    l = list(getints())

    lo = 0
    hi = max(l)

    while lo != hi:
        mid = (lo + hi + 1) // 2
        if con(mid, l)[0]:
            lo = mid
        else:
            hi = mid - 1
    print(con(lo, l)[1])

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
2 2
3
1 2 3
4
1 2 3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Make It Equal
time_limit_ms: 2000
memory_limit_mb: 512
Description: You are given an integer array $$$a$$$ of size $$$n$$$. The elements of the array are numbered from $$$1$$$ to $$$n$$$.

You can perform the following operation any number of times (possibly, zero): choose an index $$$i$$$ from $$$1$$$ to $$$n$$$; decrease $$$a_i$$$ by $$$2$$$ and increase $$$a_{(i \bmod n) + 1}$$$ by $$$1$$$.

After you perform the operations, all elements of the array should be non-negative equal integers.

Your task is to calculate the minimum number of operations you have to perform.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of operations you have to perform. If it is impossible to make all elements of the array equal, print -1.

Examples:
input:
3
2
1 1
3
1 3 2
4
2 1 2 6
output:
0
-1
3

Note:

Buggy Code:
from __future__ import annotations

import bisect  # noqa
import heapq  # noqa
import math  # noqa
import random  # noqa
import statistics  # noqa
import sys
from bisect import bisect_left as lower_bound
from bisect import bisect_right as upper_bound
from collections import Counter, defaultdict, deque  # noqa
from copy import deepcopy  # noqa
from datetime import datetime  # noqa
from fractions import Fraction  # noqa
from functools import lru_cache  # noqa
from itertools import (  # noqa
    permutations, combinations  # difference is that order matters for permutations but not for combinations
)
from typing import Iterator  # noqa

# rewrite input
# sys.stdin = open("cutting.in", "r")
# sys.stdout = open("cutting.out", "w")
user_input = sys.stdin.readline

# allow big recursion
sys.setrecursionlimit(10**5)

# Magic no recursion
from types import GeneratorType  # noqa
def bootstrap(f, stack=[]):  # noqa
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        to = f(*args, **kwargs)
        while True:
            if type(to) is GeneratorType:
                stack.append(to)
                to = next(to)
            else:
                stack.pop()
                if not stack:
                    break
                to = stack[-1].send(to)
        return to

    return wrappedfunc

def get_int() -> int:
    return int(user_input())

def line_integers() -> list[int]:
    return list(map(int, user_input().split()))

def read_matrix(n: int) -> list[list[int]]:
    return [line_integers() for _ in range(n)]

def read_matrix_str(n: int) -> list[list[str]]:
    return [get_string(as_list=True) for _ in range(n)]

def read_matrix_str_blank_separated(n: int) -> list[list[str]]:
    return [get_string(as_list=False).split() for _ in range(n)]

def get_string(as_list: bool = False) -> str | list[str]:
    input_string = user_input()
    if as_list:
        return list(input_string[: len(input_string) - 1])
    else:
        return input_string[: len(input_string) - 1]

def invr() -> Iterator[int]:
    return map(int, user_input().split())

def partitions(partitions_n: int):
    partitions_a = [0 for _ in range(partitions_n + 1)]
    k_ = 1
    y_ = partitions_n - 1
    while k_ != 0:
        x_ = partitions_a[k_ - 1] + 1
        k_ -= 1
        while 2 * x_ <= y_:
            partitions_a[k_] = x_
            y_ -= x_
            k_ += 1
        l_ = k_ + 1
        while x_ <= y_:
            partitions_a[k_] = x_
            partitions_a[l_] = y_
            yield partitions_a[: k_ + 2]
            x_ += 1
            y_ -= 1
        partitions_a[k_] = x_ + y_
        y_ = x_ + y_ - 1
        yield partitions_a[: k_ + 1]

def gen_suffix_array(s_: str) -> list[int]:
    def radix_sort(p_: list[int], c_: list[int]) -> list[int]:
        count: list[int] = [0 for _ in range(len(p_))]
        for x in p_:
            count[c_[x]] += 1
        new_p: list[int] = p_.copy()
        pos: list[int] = [0 for _ in range(len(p_))]
        for i in range(1, len(p_)):
            pos[i] = pos[i-1] + count[i-1]
        for x in p_:
            new_p[pos[c_[x]]] = x
            pos[c_[x]] += 1

        return new_p
    s_ += "$"
    n: int = len(s_)
    a: list[tuple[str, int]] = [(s_[i], i) for i in range(n)]
    a.sort(key=lambda x: x[0])
    p: list[int] = [a[i][1] for i in range(n)]
    c: list[int] = [0] * n
    c[p[0]] = 0
    for i in range(1, n):
        if a[i][0] == a[i-1][0]:
            c[p[i]] = c[p[i-1]]
        else:
            c[p[i]] = c[p[i-1]] + 1
    k: int = 1
    while (1 << k) <= 2*n:
        p = [(p[i] - (1 << (k-1))) % n for i in range(n)]
        p = radix_sort(p, c)

        c_new: list[int] = [0] * n
        prev: tuple[int, int] = (c[p[0]], c[(p[0] + (1 << (k-1))) % n])
        for i in range(1, n):
            curr: tuple[int, int] = (c[p[i]], c[(p[i] + (1 << (k-1))) % n])
            if prev == curr:
                c_new[p[i]] = c_new[p[i-1]]
            else:
                c_new[p[i]] = c_new[p[i-1]] + 1
            prev = curr
        c = c_new
        k += 1
        if c_new[p[n-1]] == n - 1:
            break
    return p

def gen_suffix_array_and_lcp(s_: str) -> tuple[list[int], list[int]]:
    def radix_sort(p_: list[int], c_: list[int]) -> list[int]:
        count: list[int] = [0 for _ in range(len(p_))]
        for x in p_:
            count[c_[x]] += 1
        new_p: list[int] = p_.copy()
        pos: list[int] = [0 for _ in range(len(p_))]
        for i in range(1, len(p_)):
            pos[i] = pos[i-1] + count[i-1]
        for x in p_:
            new_p[pos[c_[x]]] = x
            pos[c_[x]] += 1

        return new_p
    s_ += "$"
    n: int = len(s_)
    a: list[tuple[str, int]] = [(s_[i], i) for i in range(n)]
    a.sort(key=lambda x: x[0])
    p: list[int] = [a[i][1] for i in range(n)]
    c: list[int] = [0] * n
    c[p[0]] = 0
    for i in range(1, n):
        if a[i][0] == a[i-1][0]:
            c[p[i]] = c[p[i-1]]
        else:
            c[p[i]] = c[p[i-1]] + 1
    k: int = 1
    while (1 << k) <= 2*n:
        p = [(p[i] - (1 << (k-1))) % n for i in range(n)]
        p = radix_sort(p, c)

        c_new: list[int] = [0] * n
        prev: tuple[int, int] = (c[p[0]], c[(p[0] + (1 << (k-1))) % n])
        for i in range(1, n):
            curr: tuple[int, int] = (c[p[i]], c[(p[i] + (1 << (k-1))) % n])
            if prev == curr:
                c_new[p[i]] = c_new[p[i-1]]
            else:
                c_new[p[i]] = c_new[p[i-1]] + 1
            prev = curr
        c = c_new
        k += 1
        if c_new[p[n-1]] == n - 1:
            break

    lcp: list[int] = [0] * (n-1)
    k: int = 0
    for i in range(n-1):
        # i => where do we start (in the string) this suffix. we never start the suffix at n-1.
        # because the suffix at n-1 is $ and it is the first of the suffix array so we don't have a previous suffix to
        # compare it to.
        pi: int = c[i]  # pi => position of the suffix i in the suffix array.
        # pi is never 0 because the suffix at 0 is $
        j: int = p[pi - 1]  # j => where does the previous (in the suffix array) suffix start (in the string).
        while s_[i+k] == s_[j+k]:
            k += 1
        lcp[pi-1] = k
        k = max(k-1, 0)

    return p, lcp

def get_lps(string: str) -> list[int]:
    lps: list[int] = [0] * len(string)
    length: int = 0
    i: int = 1
    while i < len(string):
        if string[i] == string[length]:
            length += 1
            lps[i] = length
            i += 1
        else:
            if length != 0:
                length = lps[length - 1]
            else:
                lps[i] = 0
                i += 1
    return lps

def create_string_hash(string: str, n: int, p: int, mod: int) -> tuple[list[int], list[int]]:
    hash_prefixes: list[int] = [0] * (n + 1)
    powers: list[int] = [1] * (n + 1)
    for i in range(1, n + 1):
        powers[i] = (powers[i - 1] * p) % mod
    for i in range(n):
        hash_prefixes[i + 1] = (hash_prefixes[i] * p + (ord(string[i]) - ord("a") + 1)) % mod
    return hash_prefixes, powers

def get_hash(hash_prefixes: list[int], powers: list[int], mod: int, i: int, j: int) -> int:
    """
    Returns the hash of the substring s[i:j] (j excluded)
    """
    return (hash_prefixes[j] - hash_prefixes[i] * powers[j-i]) % mod

def make_nCr_mod(max_n: int, mod: int = 10**9+7):
    max_n = min(max_n, mod - 1)

    fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)
    fact[0] = 1
    for i in range(max_n):
        fact[i + 1] = fact[i] * (i + 1) % mod

    inv_fact[-1] = pow(fact[-1], mod - 2, mod)
    for i in reversed(range(max_n)):
        inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

    def nCr_mod(n, r):
        res = 1
        while n or r:
            a, b = n % mod, r % mod
            if a < b:
                return 0
            res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
            n //= mod
            r //= mod
        return res

    return nCr_mod

def sum_from_k_to_n(k_: int, n_: int) -> int:
    # k inclusive, n inclusive
    return (n_ * (n_ + 1) - k_ * (k_ - 1)) // 2

class FenwickTree:
    def __init__(self, x):
        bit = self.bit = list(x)
        size = self.size = len(bit)
        for i in range(size):
            j = i | (i + 1)
            if j < size:
                bit[j] += bit[i]

    def update(self, idx, x):
        """updates bit[idx] += x"""
        while idx < self.size:
            self.bit[idx] += x
            idx |= idx + 1

    def __call__(self, end):
        """calc sum(bit[:end])"""
        x = 0
        while end:
            x += self.bit[end - 1]
            end &= end - 1
        return x

    def find_kth(self, k):
        """Find largest idx such that sum(bit[:idx]) <= k"""
        idx = -1
        for d in reversed(range(self.size.bit_length())):
            right_idx = idx + (1 << d)
            if right_idx < self.size and self.bit[right_idx] <= k:
                idx = right_idx
                k -= self.bit[idx]
        return idx + 1, k

class SortedList:
    block_size = 700

    def __init__(self, iterable=()):
        self.macro = []
        self.micros = [[]]
        self.micro_size = [0]
        self.fenwick = FenwickTree([0])
        self.size = 0
        for item in iterable:
            self.insert(item)

    def insert(self, x):
        i = lower_bound(self.macro, x)
        j = upper_bound(self.micros[i], x)
        self.micros[i].insert(j, x)
        self.size += 1
        self.micro_size[i] += 1
        self.fenwick.update(i, 1)
        if len(self.micros[i]) >= self.block_size:
            self.micros[i:i + 1] = self.micros[i][:self.block_size >> 1], self.micros[i][self.block_size >> 1:]
            self.micro_size[i:i + 1] = self.block_size >> 1, self.block_size >> 1
            self.fenwick = FenwickTree(self.micro_size)
            self.macro.insert(i, self.micros[i + 1][0])

    def pop(self, k=-1):
        i, j = self._find_kth(k)
        self.size -= 1
        self.micro_size[i] -= 1
        self.fenwick.update(i, -1)
        return self.micros[i].pop(j)

    def __getitem__(self, k):
        i, j = self._find_kth(k)
        return self.micros[i][j]

    def count(self, x):
        return self.upper_bound(x) - self.lower_bound(x)

    def __contains__(self, x):
        return self.count(x) > 0

    def lower_bound(self, x):
        i = lower_bound(self.macro, x)
        return self.fenwick(i) + lower_bound(self.micros[i], x)

    def upper_bound(self, x):
        i = upper_bound(self.macro, x)
        return self.fenwick(i) + upper_bound(self.micros[i], x)

    def _find_kth(self, k):
        return self.fenwick.find_kth(k + self.size if k < 0 else k)

    def __len__(self):
        return self.size

    def __iter__(self):
        return (x for micro in self.micros for x in micro)

    def __repr__(self):
        return str(list(self))

class RangeQuery:
    def __init__(self, data, func):
        self.func = func
        self._data = _data = [data]
        i = 1
        n = len(_data[0])
        while 2 * i <= n:
            prev = _data[-1]
            _data.append(
                [
                    func(prev[j], prev[j + i])
                    for j in range(n - 2 * i + 1)
                ]
            )
            i <<= 1

    def query(self, start, stop):
        """func of data[start, stop)"""
        if start >= stop:
            return 0
        depth = (stop - start).bit_length() - 1
        return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

    def __getitem__(self, idx):
        return self._data[0][idx]

class Treap:
    def __init__(self, key: int):
        self.key = key  # BST in regards to key (IF INORDER TRAVERSAL = SORTED ORDER)
        self.priority = random.randint(0, 10**6)  # heap in regards to priority
        self.size = 1
        self.left = self.right = None

def split_treap(my_treap: Treap | None, n_in_left: int) -> tuple[Treap | None, Treap | None]:
    # returns left_treap, right_treap roots
    # n_in_left is the number of nodes in the left treap
    if my_treap is None:
        return None, None
    if n_in_left <= 0:
        return None, my_treap
    if my_treap.left is not None and my_treap.left.size >= n_in_left:
        # it means the my_treap node (root of my current treap) won't be in the left_treap
        left_treap, my_treap.left = split_treap(my_treap.left, n_in_left)
        my_treap.size -= n_in_left
        return left_treap, my_treap
    else:
        # it means my_treap.left.size > n_in_left, so the my_treap node (root of my current treap) will be in the
        # left_treap
        additional_to_split = n_in_left - ((my_treap.left.size if my_treap.left is not None else 0) + 1)
        my_treap.right, right_treap = split_treap(my_treap.right, additional_to_split)
        my_treap.size = n_in_left
        return my_treap, right_treap

def merge_treap(treap_left: Treap | None, treap_right: Treap | None) -> Treap | None:
    # IF YOU WANT INORDER TRAVERSAL = SORTED ORDER REGARDING KEY for your resulting Treap:
    # Then we assume treap_left and treap_right are ordered (all keys in treap_left are smaller than the keys in
    # treap_right)
    # IF YOU DON'T CARE ABOUT INORDER TRAVERSAL = SORTED ORDER REGARDING KEY for your resulting Treap, then all good
    if treap_left is None:
        return treap_right
    if treap_right is None:
        return treap_left
    if treap_left.priority > treap_right.priority:
        treap_left.size += treap_right.size
        treap_left.right = merge_treap(treap_left.right, treap_right)
        return treap_left
    else:
        treap_right.size += treap_left.size
        treap_right.left = merge_treap(treap_left, treap_right.left)
        return treap_right

def inorder_traversal(treap: Treap | None) -> list[int]:
    if treap is None:
        return []
    return inorder_traversal(treap.left) + [treap.key] + inorder_traversal(treap.right)

def solve() -> None:
    """
    Additional test case
    1
    3
    15 1 1

    8
    """
    n: int = get_int()
    a: list[int] = line_integers()
    a_copy = a.copy()

    def is_feasible(target: int) -> bool:
        a = a_copy.copy()
        for _ in range(5):
            for i in range(n):
                a_i: int = a[i]
                if a_i > target:
                    a[i] -= 2 * (((a_i - target) // 2) + (a_i - target) % 2)

                    nxt_idx: int = (i + 1) % n
                    a[nxt_idx] += 1 * (((a_i - target) // 2) + (a_i - target) % 2)

        return all([x == target for x in a])

    targets: list[int] = [i * n for i in range((sum(a) // n) + 1)]
    l_ptr: int = -1
    r_ptr: int = len(targets) - 1
    while l_ptr < r_ptr:
        mid: int = (l_ptr + r_ptr + 1) // 2
        if is_feasible(targets[mid] // n):
            l_ptr = mid
        else:
            r_ptr = mid - 1

    if r_ptr == -1:
        print(-1)
        return
    print(sum(a) - targets[l_ptr])

if __name__ == "__main__":
    n_tests: int = get_int()
    test_nb: int
    for test_nb in range(n_tests):
        solve()

    # solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the given code, we need to consider edge cases and scenarios that can make the algorithm fail. Here are the steps to think through this:

1. **Edge Case: Small Array with Few Elements**:
   - Test arrays with very small sizes (e.g., 2 or 3) to ensure the algorithm handles small inputs correctly.

2. **Edge Case: Large Array with Few Elements**:
   - Test arrays with a large number of elements (e.g., close to the upper limit of 200,000) to check the performance and correctness of the algorithm.

3. **Edge Case: All Elements are Equal**:
   - Test cases where all elements are already equal to ensure the algorithm correctly returns 0 operations.

4. **Edge Case: Impossible to Make All Elements Equal**:
   - Test cases where it is impossible to make all elements equal, such as when the sum of the array is not divisible by the number of elements.

5. **Edge Case: Large Values in the Array**:
   - Test cases with large values (e.g., close to 10^9) to ensure the algorithm handles large values correctly.

6. **Edge Case: Mixed Values**:
   - Test cases with a mix of large and small values to check the algorithm's ability to handle varied inputs.

Given these considerations, let's create a small-scale test input that is complete and valid:

```plaintext
3
2
1 1
3
15 1 1
4
2 1 2 6
```

This test input includes:
1. A case with 2 elements that are already equal.
2. A case with 3 elements where it is impossible to make all elements equal.
3. A case with 4 elements that requires a specific number of operations to make all elements equal.

This should be sufficient to expose any bugs in the given code.