main(n,s,e,x,f){
	for(;scanf("%d",&n),n;printf("%s%d-%d\n",f?" ":"",s,e))
		for(scanf("%d",&s),e=s,f=0;--n;){
			scanf("%d",&x);
			if(x-e==1){e++;continue;}
			printf("%s%d-%d",f?" ":"",s,e);
			s=e=x,f=1;
		}
	return 0;
}