End-Balanced Subarrays
시간 제한1초메모리 제한1024 MB
길이가 2 이상인 부분 배열 가운데 양 끝 원소의 합이 그 사이 원소들의 합과 같은 것의 개수를 센다.
문제
You are given an array of integers. A sub-array is considered end-balanced if and .
For example, the subarrays , , and are considered end-balanced, and the subarrays , , and are not.
How many subarrays of are end-balanced?
입력
The first line of the input contains a single integer () --- the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer () --- the size of the array .
The second line of each test case contains integers () --- the elements of the array .
It is guaranteed that the sum of over all test cases does not exceed .
출력
For each test case, print a single integer --- the number of end-balanced subarrays of .
힌트
The end-balanced subarrays in the first test case are:
The end-balanced subarrays in the second test case are:
The end-balanced subarrays in the third test case are: