// Aizu Vol-10 1051: Citation Format
// 2017.8.18 bal4u@uu

#include <stdio.h>

int main()
{
	int n;
	int i, f, last, s, p;

	while (scanf("%d", &n) && n) {
		scanf("%d", &s), last = s, f = 1;
		for (i = 1; ; i++) {
			if (i < n) {
				scanf("%d", &p);
				if (p == last + 1) { last++; continue; }
			}
			if (f) f = 0;
			else putchar(' ');
			if (last == s) printf("%d", s);
			else printf("%d-%d", s, last);
			if (i >= n) { putchar('\n'); break; }
			s = last = p;
		}
	}
	return 0;
}