#include<string.h>
#include<stdio.h>

int main(){
int up;//??????
bool b[10000][51];
	int c=-1;
	int i2;
	int itizi;
	int i;	
	int con;//?¶??????????
	int saisyo[10000];
	for(i=0;c==-1;i++){
		scanf("%d",&up);
		if(up==0){c=i;break;}
		scanf("%d",&itizi);
		saisyo[i]=itizi;
		b[i][itizi]=true;	
		for(i2=1;i2<up;i2++){
			scanf("%d",&itizi);
			b[i][itizi]=true;
		}
	}
	
	for(i=0;i<c;i++){
		con=-1;
		for(i2=1;i2<=50;i2++){
			if(con==-1&&b[i][i2]==true){
				con=i2;
			}	
			else if(b[i][i2]==true){}
			else if(con!=-1&&b[i][i2]!=true){
				if(con==saisyo[i])printf("%d-%d",con,i2-1);
				else printf(" %d-%d",con,i2-1);
				con=-1;	
			}
		}
		printf("\n");
	}
return 0;
}