/*
AizuOnline A1051
Citation Format
*/
#include <stdio.h>


main()
{
  int n;
  /*  int pages[50]; */
  struct {int from;int to;} quotes[25];
  int i;
  int p,q;
  while(EOF != scanf("%d",&n) && n)
    {
      q=-1;
      for(i=0;i<n;i++)
	{
	  scanf(" %d",&p);

	  if(i==0 || p > quotes[q].to+1)
	    {
#ifdef DEBUG 
	      printf("A:%d",p);	 
#endif     
	      q++;
	      quotes[q].from = p;
	      quotes[q].to = p;
	    }
	  else
	    {
#ifdef DEBUG
	      printf("B:%d",p);
#endif
	      quotes[q].to++;
	    }
	}
      for(i=0;i<=q;i++)
	{
	  if(quotes[i].from == quotes[i].to)
	    printf("%d ",quotes[i].from);
	  else
	    printf("%d-%d ",quotes[i].from,quotes[i].to);
	}
      printf("\n");
    }




return(0);
}