#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

typedef pair< int, int > pii;

int main() {
	int n;
	
	while (cin >> n, n) {
		vector< pii > vp;
		
		int st = -1, prv = -1;
		
		for_(i,0,n) {
			int a;
			cin >> a;
			
			if (prv != a - 1) {
				if (st != -1) vp.push_back(pii(st, prv));
				st = a;
			}
			
			prv = a;
		}
		
		vp.push_back(pii(st, prv));
		
		int m = vp.size();
		
		for_(i,0,m) {
			if (vp[i].first == vp[i].second) cout << vp[i].first;
			else cout << vp[i].first << "-" << vp[i].second;
			cout << (i < m - 1 ? " " : "\n");
		}
	}
}