def getstr(l):
nl = [l[0],]
for i in range(1, len(l)):
if l[i] - nl[-1] > 1 and nl[-2] != '-':
nl.append('-')
nl.append(l[i])
return nl
l = [1,2,3,4,7,9,11,13,14,15,16,17,19]
nl = getstr(l)
print(','.join(nl).replace(',-,', '-'))