#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>nums;
		while (N--) {
			int a; cin >> a; nums.emplace_back(a);
		}
		vector<pair<int, int>>anss;
		for (int i = 0; i < nums.size(); ++i) {
			int b = nums[i];
			int c = b;
			while (i != nums.size() - 1 && c + 1 == nums[i + 1]) {
				i++;
				c++;
			}
			anss.emplace_back(b, c);
			
		}
		for (int i = 0; i < anss.size(); ++i) {
			if (anss[i].first == anss[i].second)cout << anss[i].first;
			else cout << anss[i].first << '-' << anss[i].second;
			if (i == anss.size() - 1)cout << endl;
			else cout << ' ';
		}
	}
	return 0;
}