#include <stdio.h>
#include <memory.h>
int main(void){
    int num,start,end,i,line[50];
    for(;memset(line,0,sizeof(line)),i=1,scanf("%d",&num),num;){
        for(i=0;i<num;i++)
            scanf("%d",&line[i]);
        start=end=line[0];
        i=0;
        while(i<=num){
            if(end+1==line[i])
                end++;
            if(end!=line[i] || i==num){
                if(start==end)
                    printf("%d%s",start,i==num?"\n":" ");
                else
                    printf("%d-%d%s",start,end,i==num?"\n":" ");
                start=end=line[i];
            }
            i++;
        }
    }
    return 0;
}