public static void main(String args[]) throws Throwable {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		for (int N,t=1;(N=parseInt(in.readLine().trim()))!=0;t++) {
			String num="";
			int cant=0;
			sb.append("Case ").append(t).append(":\n");
			for(int i=0;i<N;i++) {
				String s=in.readLine().trim();
				if(num.length()==0||Long.parseLong(num)+cant!=Long.parseLong(s)){
					if(num.length()>1) {
						if(cant>1)sb.append(num).append("-").append(cota(num,cant)).append("\n");
						else sb.append(num).append("\n");
					}						
					num=s;cant=1;
				}
				else cant++;
			}
			if(num.length()>1) {
				if(cant>1)sb.append(num).append("-").append(cota(num,cant)).append("\n");
				else sb.append(num).append("\n");
			}	
			sb.append("\n");
		}
		System.out.print(new String(sb));
	}