#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <stack>
#include <list>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, P> P2;
typedef pair<int, pair<P, P> > PPP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int nums[50];
vector<P> res;

int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0; i < n; i++){
			cin >> nums[i];
		}
		int l = 0;
		int r = 0;
		while(l < n){
			P p;
			p.first = nums[l];
			r = l;
			while(n > r + 1&& nums[r+1] == nums[r] + 1) r++;
			p.second = nums[r];
			l = r+1;
			res.push_back(p);
		}
		for(int i = 0; i < (int)res.size(); i++){
			if(i != 0) cout << " ";
			cout << res[i].first;
			if(res[i].first != res[i].second){
				cout << "-" << res[i].second;
			}
		}
		cout << endl;
		res.clear();
	}
	return 0;
}