[Question]
  [
Related: [Tell me how many math problems I have to do!](https://codegolf.stackexchange.com/questions/51189/tell-me-how-many-math-problems-i-have-to-do)
### Challenge
Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's consecutive integer runs of length ≥ N with a single dash `-`.
### Rules
* Horizontal whitespace is irrelevant.
* You may optionally preserve the introducer, separator, and terminator characters of your language's default list format. See *Format examples*, below.
### Data examples
All these examples use `L = 3 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 24`.
`N = 3` → `3 5 - 8 10 - 12 14 16 - 22 24`
`N = 4` → `3 5 - 8 10 11 12 14 16 - 22 24`
`N = 5` → `3 5 6 7 8 10 11 12 14 16 - 22 24`
`N = 8` → `3 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 24`
### Format examples
For the inputs  
 `L = [3,5,6,7,8,10,11,12,14,16,17,18,19,20,21,22,24]` and `N = 3`  
all the below lines are examples of valid responses, both as actual lists and as strings:
```
[3,5,"-",8,10,"-",12,14,16,"-",22,24]
[3,5,-,8,10,-,12,14,16,-,22,24]
[3,5-8,10-12,14,16-22,24]
3,5-8,10-12,14,16-22,24
```
The same applies with other list formats, like `{1 2 3}` and `(1; 2; 3)` etc. In doubt? Ask!
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~132~~ 115 bytes
-17 bytes thanks to Leaky Nun
```
x,n=input()
o=[]
i=1
while x:
 t=x[0]
 while[t+i]==x[i:i+1]:i+=1
 o+=[[t,'-',t+i-1],x[:i]][i<n];x=x[i:];i=1
print o
```
[Try it online!](https://tio.run/##HcxLCsMwDATQvU@hXVqiQOSmP6c@idCyEEGxQ3Gpe3pXyWK0mDdo/ZUlJ99axRQ1rZ9yOLocWZxGct9FX0@owUGJlUdxsDdcepVojQbtSezYFnIfmQt2Q4fmAwlWDirC@kgy130u8/Z2fWsqkFvjE8IZ4YJwRbgh0Gghi7dMFhMyos3uCN7cm3tzPwlOfw "Python 2 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~26 25~~ 23 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-2 bytes thanks to Erik the Outgolfer (by bringing the if statement into the main link)
```
Ḣ;Ṫj”-
IỊ¬1;œṗ⁸¹ÇL<¥?€F
```
A dyadic link returning a list in the `[3,5,"-",8,10,"-",12,14,16,"-",22,24]` format.
**[Try it online!](https://tio.run/##AWgAl/9qZWxsef//4biiO@G5qmrigJ0tCknhu4rCrDE7xZPhuZfigbjCucOHTDzCpT/igqxG/8OnS///WzMsNSw2LDcsOCwxMCwxMSwxMiwxNCwxNiwxNywxOCwxOSwyMCwyMSwyMiwyNF3/Ng "Jelly – Try It Online")** (footer separates with spaces, to print the data example format).
### How?
```
Ḣ;Ṫj”- - Link 1, format a run: list R
Ḣ      -     head
  Ṫ    -     tail
 ;     -     concatenate
    ”- -     literal '-'
   j   -     join
IỊ¬1;œṗ⁸¹ÇL<¥?€F - Main link: list L, number N
I                - incremental differences
 Ị               - insignificant? (<=1)
  ¬              - not
   1;            - prepend a 1
       ⁸         - chain's left argument, L
     œṗ          - partition (L) at truthy indexes
              €  - for €ach row, R, in L:
             ?   -   if:
            ¥    -   condition: last two links as a dyad:
          L      -     length of R
           <     -     is less than N?
        ¹        -   then: identity - do nothing, yields R
         Ç       -   else: call the last link (1) as a monad with argument  R
               F - flatten into a single list
```
[Answer]
# Pyth, 23 bytes
```
sm?<ldvzd[hd\-ed).ga=hZ
```
[Try it online](https://pyth.herokuapp.com/?code=sm%3F%3Cldvzd%5Bhd%5C-ed%29.ga%3DhZ&input=%5B3%2C5%2C6%2C7%2C8%2C10%2C11%2C12%2C14%2C16%2C17%2C18%2C19%2C20%2C21%2C22%2C24%5D%0A4)
### How it works
```
sm?<ldvzd[hd\-ed).ga=hZkQ
                        Q    autoinitialized to eval(input())
                 .g          group by k ↦
                    =hZ          Z += 1, returning new value (Z is autoinitialized to 0)
                   a   k         absolute difference with k
 m                           map d ↦
  ?                              if
    ld                               length of d
   <  vz                             less than eval(z) (z is autoinitialized to input())
        d                        then d
         [hd\-ed)                else [d[0], '-', d[-1]]
s                            concatenate
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 24 bytes
```
óÈÄ¥YÃ®l ¨V?Zv +'-+Zo :Z
```
[Try it online!](https://tio.run/##y0osKPn///Dmwx2HWw4tjTzcfGhdjsKhFWH2UWUK2uq62lH5ClZR///7KNgqRBsrmCqYKZgrWCgYGigYGioYGikYmigYmikYmisYAgUtFYwMFIwMFYyMFIxMYrn8gHpMAA "Japt – Try It Online")
### Explanation
```
óÈ   Ä ¥ YÃ ®   l ¨ V?Zv +'-+Zo :Z
óXY{X+1==Y} mZ{Zl >=V?Zv +'-+Zo :Z}   Ungolfed
                                      Implicit: U = input array, V = input integer
óXY{      }                           Group U into runs such that for each pair X, Y:
    X+1==Y                              Y is exactly 1 more than X.
            mZ{                   }   Map each run Z to:
               Zl >=V?                  If Z has at least V items:
                      Zv     Zo           Z.unshift() and Z.pop() (the first and last items)
                         +'-+             joined with a hyphen.
                                :       Otherwise:
                                 Z        just Z.
                                      Implicit: output result of last expression
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 101 bytes
```
\d+
$*
\b(1+) (?=1\1\b)
$1X
T`X` `\b((X)|1)+\b(?=.*¶(?<-2>1)+(?(2)(?!))11)
T`X`-
-1+(?=-)|¶1+
1+
$.&
```
[Try it online!](https://tio.run/##HcoxDoJAFATQ/p9iTIjZz2YJ80XQRNxLWFBQINHCxsJYci4OwMXWjcUkkzfzeX5f73tK48NLUco4O3qFiz1HjrNKwUFu0zBhypMbdKH63GJfldvq4iXYNYuLztTFnSqp/3@QwMx90GVb6UVyimqf0gFHtOhwAmuQoIEN2IIdmPEMq2GEGayR5gc "Retina – Try It Online") Takes the space-separated list `L` on the first line and the integer `N` on the second line. Explanation: The first stage converts the input to unary. The second stage changes the space between consecutive integers to an `X`. The third stage looks for runs of consecutive integers whose length is less than `N` and changes their `X`s back to spaces. The fourth stage changes the `X`s to `-` (this was 3 bytes shorter than using `-`s in the first place.) The fifth stage deletes all integers still left in the middle of a run, as well as `N`, while the final stage converts back to decimal.
[Answer]
# Mathematica, 128 bytes
```
(s=#2;t=r=1;While[t<Length@s,If[s[[t+1]]-s[[t]]==1,r++,r=1];If[r==#,s[[t-#+3;;t]]="-";r--];t++];s//.{b___,a_,a_,c___}:>{b,a,c})&
```
  
**input**
> 
> [3,{3,5,6,7,8,10,11,12,14,16,17,18,19,20,21,22,24}]
> 
> 
> 
**output**
> 
> {3, 5, "-", 8, 10, "-", 12, 14, 16, "-", 22, 24}
> 
> 
> 
[Try it online!](https://tio.run/##HYpNC4JAFEX/SihEMXeqN5Z9vCbaBi3atRgGMdEUysXM7MTfbhrcxeGe881D3RR@qPSw8DpWHLTTxM@6@ZQmnO9l@w711eNWGW9MEGStnMBarQlOCIy55VE7rWNMSsYiYZ6KSEbspLQchLDs1@tV98qyDPl/xYj96dK9kKPol/Ph4Zo2zK6VSdAl2CHFHgfQBkQgBdqCUtAeNJ5HqA0UQSmobW@HHw "Mathics – Try It Online")
[Answer]
# APL, 38 bytes
```
{∊⍺{⍺>≢⍵:⍵⋄2⌽'-',2↑¯1⌽⍵}¨⍵⊂⍨1,1≠2-⍨/⍵}
```
[Answer]
# PHP 7, ~~137 136 134 117 110~~ 108 bytes
```
for($a=$argv,$i=2;$n=$a[$i++];$k<$a[1]||array_splice($a,$i,$k-2,"-"))for($k=print"$n ";$a[$i+$k]-++$k==$n;);
```
Takes `L` from first argument, list elements after that. Run with `-nr` or [try it online](http://sandbox.onlinephpfunctions.com/code/30d60ccc59d4658928c02510cd1bd8cadfa57685).
Replace `$L=($a=$argv)` with `$a=$argv,$L=` (+1 byte) for PHP<7.
**breakdown**
```
for($a=$argv,$i=2;              # import input
    $n=$a[$i++];                # loop $n through list elements
    $k<$a[1]||                      # 3. if streak length ($k) is >=L ($a[1])
        array_splice($a,$i,$k-2,"-")    # then replace with "-"
)
for($k=print"$n ";                  # 1. print element and space
    $a[$i+$k]-++$k==$n;);           # 2. find consecutive numbers
```
[Answer]
# Ruby, 68 bytes
```
->n,l{l.slice_when{|x,y|x<y-1}.map{|x|x[n-1]?x.minmax.uniq*?-:x}*?,}
```
Returns a string like for example `3,5-8,10-12,14,16-22,24`.
[Try it online!](https://tio.run/##pctLDoIwFEbhuatgTP423MtLjNqFNMSggUgCDYrEEsraKwNXoMNzku85XWffnLw4G3RLJ8euvdWX9702i7OYnT3OglbZV8PWzmojqFRW9q3pKysn0z5CJQ52DRVWP0yvMWh0gkDHSJEhxx4UgQjEoASUgXLQNgtwBCYwgxNwWpa7r47/0vyT9h8 "Ruby – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 40 bytes
```
;@((](,_,{:)/)^:(<:#)&.>]<;.1~1,1<}.-}:)
```
[Try it online!](https://tio.run/##DchBDoIwEAXQPaf40cR0klr7xwI6VMNFkIWBGDcewODVa9/yvUtZcTMMo3OT87P/mpzkYS7bXg7hPuUh8EfPvIXjZtI0y/P1gQ84I6HFBXl06y5iljotOvT1GEGCCiawA3uw5hUaoYQqNJXyBw "J – Try It Online")
Uses `_` instead of `-`.
## Explanation
```
;@((](,_,{:)/)^:(<:#)&.>]<;.1~1,1<}.-}:)  Input: integer N (LHS), array L (RHS)
                                  }.      Behead L
                                     }:   Curtail L
                                    -     Subtract elementwise to get the increments
                                1<        Test if greater than 1
                              1,          Prepend a 1
                        ]                 Get L
                         <;.1~            Partition L into boxes using the previous array
                     & >                  Operate on each box (partition) with N
              ^:                            If
                   #                          The length of the partition
                 <:                           Is greater than or equal to N
   (](     )/)                                Reduce (right-to-left) it using
         {:                                     Tail
       _,                                       Prepend _
      ,                                         Append to LHS
                     &.>                    Box the result
;@                                        Raze - join the contents in each box
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 23 bytes
```
D0J¨pε⁽ṅḋ•ƛL⁰≥[₍ht\-Y}f
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJEMErCqHDOteKBveG5heG4i+KAosabTOKBsOKJpVvigo1odFxcLVl9ZiIsIiIsIlszLCA1LCA2LCA3LCA4LCAxMCwgMTEsIDEyLCAxNCwgMTYsIDE3LCAxOCwgMTksIDIwLCAyMSwgMjIsIDI0XVxuNCJd)
23 bytes seems to be the standard here, so I figured I'd add my own 23 byter. Takes `L`ist then `N`.
## Explained
```
D0J¨pε⁽ṅḋ•ƛL⁰≥[₍ht\-Y}f
D0J                     # Push 3 copies of the input and append 0 to the last
   ¨pε                  # get the absolute difference of each overlapping pair
      ⁽ṅḋ               # group by diff <= 1
         •              # mold to shape
          ƛ          }  # to each consecutive run:
           L⁰≥[         #   if the length is >= N
               ₍ht\-Y   #     [head, "-", tail]
                      f # flatten that
```
[Answer]
# Jelly, ~~39~~ ~~37~~ 36 bytes
```
IỊṣ0;€1ṁ@
ÇL€<Ɠ¬TịÇḊ€Ṗ€F;€”-FyµŒgQ€F
```
[Try it online](https://tio.run/##y0rNyan8/9/z4e6uhzsXG1g/alpj@HBnowPX4XYfINvm2ORDa0Ie7u4@3P5wRxdQ4OHOaUDSDaTuUcNcXbfKQ1uPTkoPBIn9P9zu/t/kf7SxjqmOmY65joWOoYGOoaGOoZGOoYmOoZmOobmOIVDQUsfIQMfIUMfISMfIJBYA)
Takes the array via arguments, and the integer via STDIN. The TIO link uses the footer `ÇG` so the output is space-separated.
**How?** (Array: `a`, Integer: `n`)
```
(`f`)
IỊṣ0;€1ṁ@
I          Deltas of `a`
 Ị         Insignificant (x -> abs(x)<=1) applied to each element
  ṣ0       Split at occurrences of `0`.
    ;€1    Append `1` to each element
       ṁ@  `a` shaped like that
ÇL€<Ɠ¬TịÇḊ€Ṗ€F;€”-FyµŒgQ€F
Ç                            `f`
 L€                          Length of each element
   <Ɠ                        x -> x < n applied to each element
     ¬                       Logical not of each element (because Jelly doesn't have <= nor >= atoms)
      T                      Nonzero indexes
       ịÇ                    Index `f` at those indexes
         Ḋ€Ṗ€                x -> x[1:-1] applied to each element
             F               Flatten
              ;€”-           Append a hyphen to each element
                  F          Flatten
                   y         Translate (replaces all elements to be deleted with a hyphen)
                    µ        Start a new monadic link
                     Œg      Group runs of equal elements
                       Q€    Uniquify each element (make runs of hyphens one hypen)
                         F   Flatten, yet again.
```
I'm guessing I fell ... *flat* on this one.
[Answer]
# JavaScript (ES6), ~~126~~ 119 bytes
```
(e,c)=>{for(i=0,R='';i<e.length;R+=(R&&',')+(u-m>=c?m+'-'+--u:e.slice(z,i))){m=u=e[i],z=i;while(e[++i]==++u);}return R}
```
An anonymous function. Takes input in the order `Array L, Integer N` and returns the result as a comma-separated string.
```
M=(e,c)=>{for(i=0,R='';i<e.length;R+=(R&&',')+(u-m>=c?m+'-'+--u:e.slice(z,i))){m=u=e[i],z=i;while(e[++i]==++u);}return R}
console.log(M(eval(prompt()),+prompt()))
```
[Answer]
# Dyalog APL v16.0, ~~82~~ ~~80~~ ~~78~~ ~~76~~ ~~75~~ ~~65~~ 62 bytes
```
{S/⍨1,⍨2≠/S←'-'@(⍸⊃∨/(-0,⍳⍺-3)⌽¨⊂(⍴⍵)↑∧/¨(⍺-1),/¯1⌽1=-2-/⍵)⊢⍵}
```
Wow, this is ... bad. There's probably a much much shorter solution with stencil.
[Try it online!](https://tio.run/##nYw9CsJAEIV7T/E6E3DZzCb@FYJ3yAlCJCIEFKxEbBQkBle0sBcbt7NQQQSbHGUuElfxAtrMg/e9b6JRKnqTKB32RZxG4/EgLsuEl9tpKFkbqtmjeHWQoe2qotp1WN85X3BmpCM8iy@sH8J3ef0sDOdzy6@sby4vd5ydZGGcNye3Josz2RF1hBLys8iPNmYV3uztbx8JfNTRQBMtkAcikAIFoAaoCbJlG8qDIigFFXy94E@v/qfX@tUryxc)
Golfing suggestions welcome!
]