public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int times = 1;
		StringBuilder br = new StringBuilder();
		while ((line = in.readLine()) != null) {
			if (line.equals("0"))
				break;
			n = Integer.parseInt(line);
			int arr[] = new int[ n ];
			for (int i = 0; i < arr.length; i++) {
				arr[i] = Integer.parseInt(in.readLine());
			}
			res = new int[ (((n - 1) * (n)) / 2) ];
			int k = 0;
			for (int i = 0; i < arr.length; i++) {
				for (int j = i + 1; j < arr.length; j++) {
					if (i != j) {
						res[k] = arr[i] + arr[j];
						k++;
					}
				}
			}

			Arrays.sort(res);

			int q = Integer.parseInt(in.readLine());
			// System.out.println("case " + times + ":");
			br.append("Case " + times + ":").append("\n");
			for (int i = 0; i < q; i++) {
				int date = Integer.parseInt(in.readLine());
				if (date > res[res.length - 1]) {
					br.append("Closest sum to " + date + " is " + res[res.length - 1] + ".").append("\n");
					// System.out.println("Closest sum to " + date + " is " +
					// res[res.length - 1] + ".");
				} else if (date < res[0]) {
					br.append("Closest sum to " + date + " is " + res[0] + ".").append("\n");
					// System.out.println("Closest sum to " + date + " is " +
					// res[0] + ".");
				} else
					br.append("Closest sum to " + date + " is " + binarySearch(date) + ".").append("\n");
				// System.out.println("Closest sum to " + date + " is " +
				// binarySearch(date) + ".");
			}
			times++;

		}
		System.out.print(br);
	}