Happy Subarrays

아직 제출이 없습니다시간 제한25초메모리 제한1024 MB

문제

Let us define F(B,L,R)F(B, L, R) as the sum of a subarray of an array BB bounded by indices LL and RR (both inclusive). Formally, F(B,L,R)=B_L+B_L+1++B_RF(B, L, R) = B\_L + B\_{L+1} + \cdots + B\_R.

An array CC of length KK is called a happy array if all the prefix sums of CC are non-negative. Formally, the terms F(C,1,1),F(C,1,2),,F(C,1,K)F(C, 1, 1), F(C, 1, 2), \dots, F(C, 1, K) are all non-negative.

Given an array A\mathbf{A} of N\mathbf{N} integers, find the result of adding the sums of all the happy subarrays in the array A\mathbf{A}.

입력

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow.

Each test case begins with one line consisting an integer N\mathbf{N} denoting the number of integers in the input array A\mathbf{A}. Then the next line contains N\mathbf{N} integers A_1,A_2,,A_N\mathbf{A\_1}, \mathbf{A\_2}, \dots, \mathbf{A\_N} representing the integers in given input array A\mathbf{A}.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the result of adding the sums of all happy subarrays in the given input array A\mathbf{A}.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 800A_i800-800 \le \mathbf{A\_i} \le 800, for all ii.