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.

**Input:**

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.

**Output:**

Corresponding to each test case, in a new line, print the minimum initial energy required to cross the street.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 100

-500 ≤ A[i] ≤ 500

**Example:**

**Input**

2

5

4 -10 4 4 4

5

3 5 2 6 1

**Output**

7

1

**Explanation**

(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.

vamsikrishna55 | 162 |

Vagesh Verma | 154 |

UrGuru | 133 |

chaolinyu | 98 |

Akhil varma | 97 |

abducodes | 650 |

harshtyagi36 | 304 |

highway_to_hell | 252 |

Akhil varma | 250 |

arpit_anshuman | 250 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.