#include <stdio.h>
#define N 50

int main( void ) {

  while( 1 ) {
    int i, n;
    int page[ N ], cont[ N ] = { 0 };

    scanf( "%d", &n );
    if( !n ) break;

    scanf( "%d", &page[ 0 ] );

    for( i = 1; i < n; i++ ) {
      scanf( "%d", &page[ i ] );

      if( page[ i-1 ] + 1 == page[ i ] )
        cont[ i-1 ] = 1;
    }

    for( i = 0; i < n; i++ ) {
      printf( "%d", page[ i ] );

      if( cont[ i ] ) {
        printf( "-" );

        for( i++; cont[ i ]; i++ ) ;

        printf( "%d", page[ i ] );
      }

      if( i < n-1 )
        printf( " " );
    }
    printf( "\n" );
  }

  return( 0 );
}