package Game_with_numbers;
import java.io.FileInputStream;
import java.util.Scanner;
public class Solution {
static int[] a;
static int m = 0, m1 = 0;;
static int[][] x;
public static void main(String args[]) throws Exception{
System.setIn(new FileInputStream("src/Game_with_numbers/input.txt"));
Scanner sc = new Scanner(System.in);
int T;
int Answer;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++){
int n = sc.nextInt();
a = new int[n];
for(int i = 0; i < n; i++){
a[i] = sc.nextInt();
}
String s = "";
for(int i = 0; i < n; i++){
s += String.valueOf(a[i]);
}
m = 0;
m1 = 0;
String s1 = s;
int n1 = n;
x = new int[n][n];
TryTM(n);
/*for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
System.out.print(x[i][j] + " ");
}
System.out.println();
}*/
//Try(s,n);
//System.out.println(x[0][n-1]);
/*s = removeCharAt(s, 0);
System.out.println(s.charAt(0));*/
System.out.println("Case #" + test_case);
System.out.println(m + " " + x[0][n-1]);
}
}
public static void TryTM(int n){
for(int i = 0; i < n; i++){
x[i][i] = a[i];
}
for(int k = 1; k < n; k++){
for(int i = 0; i < n-k; i++){
int j = i+k;
int sum = 0;
for(int u = i; u <= j; u++){
sum += a[u];
}
int res1 = sum - x[i+1][j];
int res2 = sum - x[i][j-1];
if(res1 > res2){
x[i][j] = res1;
}else x[i][j] = res2;
}
}
}
public static void Try(int x, int y, int n){
}
/*public static void Try(String b, int n){
if(n == 0) return;
else{
if(CharToSo(b.charAt(0)) > CharToSo(b.charAt(n-1))){
m += CharToSo(b.charAt(0));
b = removeCharAt(b, 0);
n--;
if(CharToSo(b.charAt(0)) > CharToSo(b.charAt(n-1))){
b = removeCharAt(b, n-1);
n--;
}else{
b = removeCharAt(b, 0);
n--;
}
}else{
m += CharToSo(b.charAt(n-1));
b = removeCharAt(b, n-1);
n--;
if(CharToSo(b.charAt(0)) > CharToSo(b.charAt(n-1))){
b = removeCharAt(b, n-1);
n--;
}else{
b = removeCharAt(b, 0);
n--;
}
}
Try(b, n);
}
}*/
public static int CharToSo(char a){
return Integer.parseInt(String.valueOf(a));
}
public static String removeCharAt(String s, int pos) {
return s.substring(0, pos) + s.substring(pos + 1);
}
}