import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t > 0) {
            t--;
            int n = scanner.nextByte();
            long sequenceArray[] = new long[n];
            for (int i = 0; i < n; i++) {
                sequenceArray[i] = scanner.nextLong();
            }

        }
    }

    public static long getMaxumimSubSequenceSum(long sequenceArray[]) {
        int maximumArrayLength = 0;
        long maximumArrayLengthSum = Integer.MIN_VALUE;
        int currentArrayElementCounter = 0;
        long currentArraySum = 0;

        for (int i = 0; i < sequenceArray.length; i++) {

            currentArrayElementCounter++;
            currentArraySum += sequenceArray[i];
            if (currentArrayElementCounter == maximumArrayLength && currentArraySum > maximumArrayLengthSum) {
                maximumArrayLengthSum = currentArraySum;
            } else if (currentArrayElementCounter > maximumArrayLength) {
                maximumArrayLength = currentArrayElementCounter;
                maximumArrayLengthSum = currentArraySum;
            }

            if (i < sequenceArray.length - 1) {
                if (areSameSignNumbers(sequenceArray, i, i + 1)) {
                    currentArrayElementCounter = 0;
                    currentArraySum = 0;
                }

            }

        }

        return maximumArrayLengthSum;
    }

    private static boolean areSameSignNumbers(long[] sequenceArray, int i, int j) {
        return sequenceArray[i] > 0 && sequenceArray[j] > 0 ||  sequenceArray[i] < 0 && sequenceArray[j] < 0;
    }

}