text: #include<bits/stdc++.h>
  using namespace std;
  
  
   // } Driver Code Ends
  class Solution{
      public:
      // arr: input array
      // n: size of array
      //Function to find the sum of contiguous subarray with maximum sum.
      int maxSubarraySum(int arr[], int n)
      {
          int sum = 0;
          int best = INT_MIN;
          for(int i = 0; i < n; i++)
          {
              sum = max(arr[i], sum + arr[i]);
              best = max(best, sum);
          }
          return best;
          
          // Your code here
          
      }
  };
  
  // { Driver Code Starts.
  
  int main()
  {
      int t,n;
      
      cin>>t; //input testcases
      while(t--) //while testcases exist
      {
          
          cin>>n; //input size of array
          
          int a[n];
          
          for(int i=0;i<n;i++)
              cin>>a[i]; //inputting elements of array
              
          Solution ob;
          
          cout << ob.maxSubarraySum(a, n) << endl;
      }
  }
    // } Driver Code Ends
  