#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

int pages[50];

int main()
{
  int n;
  while (scanf("%d", &n), n) {
    REP(j, n) {
      scanf("%d", &pages[j]);
    }
    pages[n] = 10000000;
    int a = pages[0], c = 1;
    bool first = true;
    FOR(j, 1, n+1) {
      if (pages[j] != pages[j-1] + 1) {
        if (first)
          first = false;
        else
          printf(" ");
        if (c == 1)
          printf("%d", a);
        else
          printf("%d-%d", a, pages[j-1]);
        a = pages[j];
        c = 1;
      } else {
        ++c;
      }
    }
    puts("");
  }
}