J. Sublime Replacement
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A non-decreasing subarray of an array $$$a$$$ of length $$$n$$$ is a contiguous segment $$$a_i, a_{i+1}, \ldots, a_j$$$ where $$$1 \leq i \leq j \leq n$$$ and $$$a_i \leq a_{i+1} \leq \cdots \leq a_j$$$.

The score of an array $$$a$$$ is defined as the maximum of $$$a_i + a_{i+1} + \cdots + a_j$$$ over all non-decreasing subarrays of $$$a$$$.

You are given an array $$$a$$$ of $$$n$$$ integers, where some elements are equal to $$$-1$$$. Your task is to replace each $$$-1$$$ with a positive integer from the range $$$[1, 10^9]$$$ (inclusive) such that the score of the resulting array is maximized.

Input

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 3 \cdot 10^5$$$) — the length of the array.

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$ or $$$a_i = -1$$$).

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.

Output

For each test case, output a single integer — the maximum possible score after optimally replacing all $$$-1$$$ values.

Example
Input
3
4
1 3 2 4
5
4 3 -1 -1 2
1
1
Output
6
2000000003
1
Note

In the first test case, the best subarray is from index $$$3$$$ to $$$4$$$, which is $$$[2, 4]$$$, and it has a sum of $$$6$$$. This is the maximum score over all non-decreasing subarrays of the array.

In the second test case, we can replace both $$$-1$$$ with $$$10^9$$$, resulting in $$$[4, 3, 10^9, 10^9, 2]$$$. The best subarray is from index $$$2$$$ to $$$4$$$, which is $$$[3, 10^9, 10^9]$$$, and it has a sum of $$$2000000003$$$. This is the maximum possible score after replacing all $$$-1$$$ values.