#include <iostream>
#include <algorithm>
using namespace std;
int main(){

  
  while(true){
    int n;
    cin >> n;
    //    for(int i = 0;i < 10;i++){}

    if(n == 0)return 0;
    
    int a[n+1];
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
    a[n+1]=100000000;
    int tmp = 0;

    int flag = 0;
    
    for(int i = 0;i < n;i++){
      
      /*if(n-1 == i){
	if(flag == 0){
	  flag = 1;	  
	  cout << a[i];
	}else {
	  
	  cout << " " <<  a[i];
	}
	}*/
      if(a[i]+1 == a[i+1]){
	tmp = a[i];
	i++;
	while(a[i]+1==a[i+1]){
	  i++;
	}
	if(flag == 0){
	  flag = 1;
	  
	  cout << tmp << "-" << a[i];
	}else {
	  
	  cout <<" "<<tmp << "-" << a[i];
	}
	
      }else{
	if(flag == 0){
	  flag = 1;	  
	  cout << a[i];
	}else {
	  
	  cout << " " <<  a[i];
	}
      }

      //if(flag != 0)
   
    }
    cout << endl;
  }
  return 0;
}