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


public class Main {

    private static void solve(MyScanner in, PrintWriter out) {
        int n = in.nextInt();

        List<Integer> pos = new ArrayList<>();
        List<Integer> neg = new ArrayList<>();

        for (int i=0;i<n;i++) {
            int x = in.nextInt();

            if (x < 0) {
                neg.add(x);
            } else {
                pos.add(x);
            }
        }

        Collections.sort(pos, Collections.reverseOrder());
        Collections.sort(neg, Collections.reverseOrder());

        int l = Math.min(pos.size(), neg.size());

        if (l == 0) {
            if (pos.isEmpty()) {
                out.println(neg.get(0));
            } else {
                out.println(pos.get(0));
            }
        } else {
            int pi = 1;
            int ni = 1;
            long ans = pos.get(0) + neg.get(0);
            l--;

            while (l-- > 0) {
                long newAns = ans;

                newAns += pos.get(pi++);
                newAns += neg.get(ni++);

                ans = Math.max(ans, newAns);
            }

            out.println(ans);
        }
    }

    public static void main(String[] args) throws FileNotFoundException {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = sc.nextInt();
        for (int i=0;i<t;i++) {
            solve(sc, out);
        }
        out.close();
    }


    public static PrintWriter out;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public MyScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}