#include <stdio.h>

int n,a,b,st,ed,mark;

int main(){    
    while(1){
        scanf("%d",&n);
        if(n == 0)
            break;
        
        mark = 0;
        while(n --){
            scanf("%d",&b);
            if(!mark){
                st = b;
                mark = 1;
            }
            else if(b != a + 1){
                ed = a;
                if(st == ed)
                    printf("%d",st);
                else
                    printf("%d-%d",st,ed); 
                printf(" ");
                st = b;
            }
            a = b;
        }
        ed = b;
        if(st == ed)
            printf("%d",st);
        else
            printf("%d-%d",st,ed); 
        printf("\n");
    }
    
    
    
    return 0;    
}