You are given an array A of length N. You take an array B of length N such that B[i] = 0 for each 1 <= i <= N. You can apply the following operation on B any number of times:
Task
Find the number of operations required to convert array B into array A by applying the given operation. Print -1 if it is impossible to do so.
Function description
Complete the function solve() provided in the editor. This function takes the following two parameters and returns the required answer:
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output format
For each test case, print the number of operations required to convert array B into array A by applying the given operation or -1 if it is impossible to do so.
Constraints
\(1 \leq T \leq 10^4 \\ 2 \leq N \leq 10^5\\ \\0\leq A_i \le 10^{9} \\ \text{Sum of $N$ over all test cases does not exceed }2\cdot 10^5\)
The first line denotes T = 2.
For the first test case
Given
Approach
For the second test case
Given
Approach