Problem11455--Bus Numbers

11455: Bus Numbers

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Your favourite public transport company LS (we cannot use their real name here, so we permuted the letters) wants to change signs on all bus stops. Some bus stops have quite a few buses that stop there and listing all the buses takes space. However, if for example buses 141, 142, 143 stop there, we can write 141–143 instead and this saves space. Note that just for two buses this does not save space.
You are given a list of buses that stop at a bus stop. What is the shortest representation of this list?

Input

The first line of the input contains one integer $N\ (1≤N≤1000)$, the number of buses that stop at a bus stop.
Then next line contains a list of $N$ space separated integers between $1$ and $1000$, which denote the bus numbers. All numbers are distinct.

Output

Print the shortest representation of the list of bus numbers. Use the format as in the example, separate numbers with single spaces and output them in sorted order.

Sample 1 Input

6
180 141 174 143 142 175

Sample 1 Output

141-143 174 175 180

Sample 2 Input

5
1 2 4 5 7

Sample 2 Output

1 2 4 5 7

Sample 3 Input

10
100 101 102 103 104 105 106 107 108 109

Sample 3 Output

100-109

10
1 101 102 103 104 105 106 107 108 1000

1 101-108 1000

Sample 4 Input

1
514

Sample 4 Output

514

HINT

Source/Category