import java.util.*;
import java.io.*;



public class Main {
    public static void main (String[] args) {
        FastScanner scanner = new FastScanner();
        int t = scanner.nextInt();
            while(t-- > 0) {
                int n = scanner.nextInt();
                int[] a = new int[n];
                int countPositive = 0, countNegative = 0;
                for (int i = 0; i < n; i++) {
                    a[i] = scanner.nextInt();
                    if(a[i] > 0) countPositive++;
                    else countNegative++;
                }
                Arrays.sort(a);
                if (countPositive == 0 || countNegative == 0) {
                    System.out.println(a[n - 1]);
                    continue;
                }

                int i;
                for (i = 0; i < n; i++) {
                    if (a[i] > 0) break;
                }
                i = i - 1;
                int j = n - 1, sum = 0;
                while (i >=0 && a[j] > 0) {
                    sum += a[i] + a[j];
                    i--;
                    j--;
                }
                if (countNegative > countPositive) sum += a[i];
                else if (countPositive > countNegative) sum += a[j];
                System.out.println(sum);
            }

    }
}

class FastScanner {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
    public FastScanner() {
        reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        tokenizer = null;
    }
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    public String nextLine() {
        try {
            return reader.readLine();
        } catch(IOException e) {
            throw new RuntimeException(e);
        }
    }
}
