import java.util.*;

public class WordPattern {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while(t != 0) {
				int n = s.nextInt();
				int[] arr = new int[n];
				int[] par = new int[n], nar = new int[n];
				for(int i = 0; i<n; i++) {
					arr[i] = s.nextInt();
				}
				int p=0,k=0;
				for(int i=0; i<n; i++) {
					if(arr[i]>0) {
						par[p] = arr[i];
						p++;
					} else {
						nar[k] = arr[i];
						k++;
					}
				}
				int pmax = 0, nmax = -10000000;
				for(int i=0; i<p; i++) {
					pmax = Math.max(pmax, par[i]);
				}
				for(int i=0; i<k; i++) {
					nmax = Math.max(nmax, nar[i]);
				}
				System.out.println(pmax+nmax);
			t--;
		}
	}
}
