#include<stdio.h>
int main(){
	int n,i,a[60];
	while(scanf("%d",&n),n){
		if(n!=1){
		for(i=0;i<n-1;i++)
			scanf("%d ",&a[i]);
		scanf("%d",&a[n-1]);
		i=1;
		
		
		printf("%d",a[0]);
		while(n-1!=i){
			if(a[i]-a[i-1]!=1){
				if(a[i-1]-a[i-2]==1)
					printf("-%d",a[i-1]);
				printf(" %d",a[i]);
			}
			
			
			
			i++;
		}
		if(a[n-1]-a[n-2]==1)
		printf("-%d\n",a[n-1]);
		else 
		printf(" %d\n",a[n-1]);
	}
	else {scanf("%d",&a[0]);
	printf("%d\n",a[0]);
	}
	}
	return 0;
}