Given an array containing positive and negative numbers. The array represents checkpoints from one end to other end of street. Positive and negative values represent amount of energy at that checkpoint. Positive numbers increase the energy and negative numbers decrease. Find the minimum initial energy required to cross the street such that Energy level never becomes 0 or less than 0.
Note : The value of minimum initial energy required will be 1 even if we cross street successfully without loosing energy to less than and equal to 0 at any checkpoint. The 1 is required for initial check point.
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of two lines. The first line of each test case consists of an integer N, where N is the size of array. The second line of each test case contains N space separated integers denoting array elements.
Corresponding to each test case, in a new line, print the minimum initial energy required to cross the street.
1 ≤ T ≤ 100
1 ≤ N ≤ 100
-500 ≤ A[i] ≤ 500
4 -10 4 4 4
3 5 2 6 1
(i) For first test case, By having an initial energy of 7 we can make sure that all the checkpoints are visited and the fuel never reaches 0 or less value.
(ii) For second test case, We need at least 1 initial energy to reach first checkpoint
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.