#include <iostream>
#include <cstring>
using namespace std;
int main(void) {
  int n;
  int page[51], first, last;
  bool flag[2] = {1, 1}, flag2;
  while(cin >> n, n) {
    memset(page, 0, sizeof(page));
    for(int i = 0 ; i < n ; i++) {
      cin >> page[i];
    }
    
    for(int i = 0 ; i < n ; i++) {

      if(page[i-1] + 1 != page[i] && page[i] + 1 != page[i+1]) {
	if(i != n-1) cout << page[i] << ' ';
	else cout << page[i];
      }

      if(page[i] + 1 == page[i+1]) {
	first = page[i];
	if(flag[0]) cout << first << '-';
	flag[0] = false;
	flag[1] = true;
      }
      
      if(page[i] + 1 != page[i+1]) {
	last = page[i];
	if(flag[1] && i != n-1) cout << last << ' ';
	else if(flag[1] && i == n-1) cout << last;
	flag[1] = false;
	flag[0] = true;
      }
    }
    cout << endl;
  }
  return 0;
}