Determine ranges from a list of values Given an unsorted list of unique, positive integers, output the shortest list of the longest possible ranges of sequential integers.

INPUT


An unsorted list of unique, positive integers


e.g. 9 13 3 11 8 4 10 15

Input can be taken from any one of the following:


stdin
command-line arguments
function arguments



OUTPUT


An ordered list of ranges or individual values printed on one line to stdout or your language's closest similar output.


If two or more sequential integers (sequential by value, not by location in the list) are present, they will be denoted as an inclusive range using -, e.g. 8-11
All other integers are simply printed with no other notation
A single space will delimit the output

Numbers not present in the input should not be in the output, e.g. 3 5 6 cannot be shortened to 3-6 because 4 is not present


EXAMPLES

Successful:

 IN&gt; 9 13 3 11 8 4 10 15 6
OUT&gt; 3-4 6 8-11 13 15

 IN&gt; 11 10 6 9 13 8 3 4 15
OUT&gt; 3-4 6 8-11 13 15

 IN&gt; 5 8 3 2 6 4 7 1
OUT&gt; 1-8

 IN&gt; 5 3 7 1 9
OUT&gt; 1 3 5 7 9


Wrong:

 IN&gt; 9 13 3 11 8 4 10 15
OUT&gt; 3-15


Range contains values not in the input

 IN&gt; 9 13 3 11 8 4 10 15
OUT&gt; 3 4 8 9 10 11 13 15


All sequential values should be represented as a range

 IN&gt; 9 13 3 11 8 4 10 15
OUT&gt; 3-4 8-9 10-11 13 15


Divided range, 8-9 and 10-11 should be 8-11

 IN&gt; 9 13 3 11 8 4 10 15
OUT&gt; 8-9 13 10-11 3-4 15


Output not ordered correctly

RULES


Standard loopholes are disallowed
If your language has a function to do this it's not allowed
You may write a full program, or a function
trailing whitespace doesn't matter


SCORING


Least bytes wins
Python 2, 123 120 bytes

N=sorted(map(int,raw_input().split(' ')));print(''.join((''if n+1in N else'-'+`n`)if n-1in N else' '+`n`for n in N)[1:])


If the input can be a list as a function argument then (thanks mbomb007 and xnor for the conditionals)

93 90 81 bytes

def f(N):print''.join((' '+`n`,`-n`*-~-(n+1in N))[n-1in N]for n in sorted(N))[1:]


(77 bytes if leading whitespace is acceptable - drop the final [1:])