#include <stdio.h>
#include <stdlib.h>

#define INT(X) \
  ( *( (int *)(X) ) )

int cmp (
  const void  * a,
  const void  * b
  )
{
  return INT( a ) - INT( b );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int d[ 50 ];
    int n;

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

    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", d + i );
    }
    qsort ( d, n, sizeof ( int ), cmp );

    printf ( "%d", *d );
    for ( i = 1; i < n; ++i )
    {
      if ( d[ i ] - d[ i - 1 ] == 1 )
      {
        while ( i + 1 < n && d[ i + 1 ] - d[ i ] == 1 ) ++i;
        printf ( "-%d", d[ i ] );
      }
      else
      {
        printf ( " %d", d[ i ] );
      }
    }
    puts ( "" );
  }

  return ( 0 );
}