#include <stdio.h>


int main(){
	int n, page[1000], start[1000], end[1000], i, j;
	
	while(1){
		scanf("%d", &n);
		if(n == 0) break;
		for(i = 0;i < 50;i++){
			page[i] = 0;
			start[i] = 0;
			end[i] = 0;
		}
		for(i = 0;i < n;i++) scanf("%d", &page[i]);
		j = 0;
		start[j] = end[j] = page[0];
		for(i = 1;i < n;i++){
			if(page[i] - page[i - 1] == 1) end[j] = page[i];
			else{
				j++;
				start[j] = end[j] = page[i];
			}
		}
		for(j = 0;start[j] != 0;j++){
			if(j != 0) printf(" ");
			if(start[j] == end[j]) printf("%d", start[j]);
			else printf("%d-%d", start[j], end[j]);
		}
		printf("\n");
	}
	
	return 0;
}