#include <stdio.h>

int main(void) {
	int s,n,r,i,t,y;
	while(scanf("%d",&t) , t != 0){
		y = 0;
		for(i = 1;i <= t;i++){
			scanf("%d",&r);
			if(i == 1){
				s = r;
				n = r;
			}
			else{
				if(r == n + 1){
					n = r;
				}
				else{
					if(s != n){
						if(y){
							printf(" ");
						}
						printf("%d-%d",s,n);
						s = r;
						n = r;
						y++;
					}
					else{
						if(y){
							printf(" ");
						}
						printf("%d",s);
						s = r;
						n = r;
						y++;
					}
				}
			}
		}
		if(s != n){
			if(y){
				printf(" ");
			}
			printf("%d-%d",s,n);
			s = r;
			n = r;
		}
		else{
			if(y){
				printf(" ");
			}
			printf("%d",s);
			s = r;
			n = r;
		}
		printf("\n");
	}
	return 0;
}