#K91362. Minimum Operations to Reduce an Array

    ID: 37959 Type: Default 1000ms 256MiB

Minimum Operations to Reduce an Array

Minimum Operations to Reduce an Array

You are given an array of integers. In one operation, you can replace two adjacent elements with their sum, thereby reducing the size of the array by one. Formally, for an array with ( n ) elements, exactly ( n - 1 ) operations are necessary to reduce it to a single element if you perform the operation on any pair of adjacent elements. Your task is to compute ( n - 1 ) for each test case.

inputFormat

The input starts with an integer ( T ), representing the number of test cases. For each test case, the first line contains an integer ( n ) (the number of elements in the array). The next line contains ( n ) space-separated integers representing the array elements.

outputFormat

For each test case, output a single integer on a new line representing the minimum number of operations required to reduce the array to a single element (i.e. ( n - 1 )).## sample

3
3
1 2 3
4
1 1 1 1
5
10 -1 2 -3 4
2

3 4

</p>