#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
  while(1){
    int n; cin >> n;
    if(n==0) break;
    vector<long long> page(n);
    for(int i=0; i<n; i++) cin >> page[i];
    sort(page.begin(),page.end());
    page.push_back((long long)1e+15);
    int start=0;
    for(int i=0; i<n; i++){
      if(page[i+1] == page[i]+1) continue;
      else{
	if(i - start != 0){
	  cout << page[start] << "-" << page[i];
	}
	else{
	  cout << page[start];
	}
	start = i+1;
      }
      if(i != n-1) cout << " ";
    }
    cout << "\n";

  }
}