#include <stdio.h>
int n, p, i, a[50];
int main() {
	while(~scanf("%d", &n), n) {
		for(i=0;i<n;i++)scanf("%d",&a[i]);p=0;
		for(i=1;i<n;i++){
			if(a[i-1]+1!=a[i]) {
				if(i-p-1)printf("%d-%d ",a[p],a[i-1]);
				else printf("%d ",a[p]);
				p=i;
			}
		}
		if(n-p-1)printf("%d-%d\n",a[p],a[n-1]);
		else printf("%d\n",a[p]);
	}
	return 0;
}