#include<iostream>
using namespace std;int main(){int n,k;while(true){cin>>n;if(n==0)break;cin>>k;int left=k,bef=k;for(int u=1;u<n;u++){cin>>k;if(bef+1!=k){if(left!=bef)cout<<left<<"-"<<bef<<" ";else cout<<left<<" ";left=k;}bef=k;}if(left!=bef)cout<<left<<"-"<<bef<<endl;else cout<<left<<endl;}return 0;}