#include<iostream>
using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		int start,prev,page;
		cin >> start; // page1;
		prev = start;
		for(int i=1; i<n; i++){
			cin >> page;
			if(page != prev+1){
				if(start==prev) cout << start << " ";
				else cout << start << "-" << prev << " ";
				start = page;
			}
			prev = page;
		}
		
		if(start == prev) cout << start << endl;
		else cout << start << "-" << prev << endl;
	}
	return 0;
}