object Main extends App{
  import scala.io.StdIn._
  val Array(n, m) = readLine().split(' ').map(_.toInt)
  solve(n, m)

  def solve(n:Int, m:Int):Unit = {
    if (n == 0 && m == 0) return
    val strangth = readLine().split(' ').map(_.toInt)
    if (minBattle(strangth, 1) < m) println(-1)
    else {
      var min = strangth.head - 1
      var max = strangth.last
      var mid = 0
      while (min < max) {
        mid = (min + max + 1) / 2
        if (minBattle(strangth, mid) >= m) {
          min = mid
        } else {
          max = mid - 1
        }
      }
      println(if (minBattle(strangth, min) >= m) min else -1)
    }
    val Array(nn, mm) = readLine().split(' ').map(_.toInt)
    solve(nn, mm)
  }

  def max(i: Int, i1: Int) = if (i > i1) i else i1
  def minBattle(enemy:Array[Int], x:Int, level:Int = 1, battleCount:Int = 1):Int = {
    if (enemy.last < level + x) return battleCount
    val nextLevel = level + max(1, x - List(enemy.lowerBound(level), enemy.upperBound(level)).map{idx => (enemy(idx) - level).abs}.max)
    return minBattle(enemy, x, nextLevel, battleCount + 1)
  }
  implicit class RichArray[+T, A <: T](private val array:Array[A]){
    def lowerBound[C <% Comparable[A]](target:C):Int = {
      var left = 0
      var right = array.length - 1
      var mid = 0
      while (left < right){
        mid = left + (right - left) / 2
        if (target.compareTo(array(mid)) <= 0){
          right = mid
        }else{
          left = mid + 1
        }
      }
      return right
    }
    def upperBound[C <% Comparable[A]](target:C):Int = {
      var left = 0
      var right = array.length - 1
      var mid = 0
      while (left < right){
        mid = left + (right - left + 1) / 2
        if (target.compareTo(array(mid)) < 0){
          right = mid - 1
        }else{
          left = mid
        }
      }
      return left
    }
  }
}

