def fl(l):
if len(l) > 2:
return '%s-%s' % (l[0], l[-1])
elif len(l) == 2:
return '%s, %s' % (l[0], l[-1])
else:
return '%s' % l[0]
def cc(l):
r = []
b = []
for i in l:
if len(b) > 0:
if i - b[-1] == 1:
b.append(i)
else:
r.append(fl(b))
b = [i]
else:
b.append(i)
else:
r.append(fl(b))
return ', '.join(r)