#include <iostream>
#include <cstdio>
using namespace std;

void solve(int n){
	int page[50];
	for(int i=0;i<n;i++){
		scanf("%d ", &page[i]);
	}
	scanf("\n");
	
	int begin = page[0];//?????????????§???????
	int end = page[0];//?????????????????????
	for(int i=1;i<n;i++){
		if(end + 1 == page[i]){
			end = page[i];
		}else{
			if(begin == end){
				printf("%d ", begin);	
			}else{
				printf("%d-%d ", begin, end);
			}
			begin = page[i];
			end = page[i];
		}
	}
	if(begin == end){
		printf("%d", begin);	
	}else{
		printf("%d-%d", begin, end);
	}
	printf("\n");
}

int main() {
	bool first = true;
	while(true){
		int n;//?????¨?????????????????°
		scanf("%d\n", &n);
		if(n==0){
			break;
		}
		solve(n);
	}
	
	return 0;
}