function package(initArr) {
let str = "";
let arr = [].concat(initArr).sort((a, b) => a-b)
arr.forEach((curItem, i) => {
if(i === 0) {
str += curItem;
}
else {
let prevItem = arr[i - 1];
let nextItem = arr[i + 1];
if(prevItem + 1 === curItem && nextItem - 1 !== curItem) {
str += `-${curItem}`;
}
if(prevItem + 1 < curItem) {
str += `, ${curItem}`;
}
}
return
})
return str;
}