public static void main(String[] args) throws IOException {
		BufferedReader in;
		StringBuilder out = new StringBuilder();
		File f = new File("entrada");
		if (f.exists()) {
			in = new BufferedReader(new FileReader(f));
		} else
			in = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(in.readLine());
		for (int i = 0; i < n; i++) {
			int s = Integer.parseInt(in.readLine());
			int arr[] = readInts(in.readLine());
			int max = -100000;
			int max2 = -100000;
			int acum = max;
			int acum2 = max;
			for (int j = 0; j < arr.length; j++) {
				if (arr[j] > 0) {
					if (acum < 0)
						acum = 0;
					acum += arr[j];
					max = Math.max(max, acum);
				} else {
					max = Math.max(max, arr[j]);
				}

				if (arr[j] < 0 && acum2 + arr[j] < 0) {
					max2 = Math.max(max2, arr[j]);
					acum2 = 0;
				} else {
					if (acum2 < 0)
						acum2 = 0;
					acum2 += arr[j];
					max2 = Math.max(max2, acum2);

				}
			}
			out.append(max2 + " " + max + "\n");
		}
		System.out.print(out);

	}