#include <bits/stdc++.h>
 
using namespace std;
 
const int SZ = 1000000;
const int INF = 1 << 30;
 
int N, M, S[100000];
int latte[SZ + 1], malta[SZ + 1];
 
bool check(int X)
{
  int curr = 1, ret = 1;
  while(curr + X <= S[N - 1]) {
    int sub = INF;
    if(curr + X > latte[curr]) sub = min(sub, latte[curr] - curr);
    sub = min(sub, curr - malta[curr]);
    curr += max(1, X - sub);
    ++ret;
  }
  return (ret >= M);
}
 
int main()
{
  while(cin >> N >> M, N) {
    for(int i = 0; i < N; i++) cin >> S[i];
    fill(begin(latte), end(latte), INF);
    fill(begin(malta), end(malta), -INF);
    for(int i = 0; i < N; i++) latte[S[i]] = S[i];
    for(int i = 0; i < N; i++) malta[S[i]] = S[i];
    for(int i = SZ - 1; i >= 0; i--) latte[i] = min(latte[i], latte[i + 1]);
    for(int i = 1; i <= SZ; i++) malta[i] = max(malta[i], malta[i - 1]);
    int ok = S[0], ng = SZ + 5;
    if(!check(ok)) {
      cout << -1 << endl;
    } else {
      while(ng - ok > 1) {
        int mid = (ok + ng) >> 1;
        if(check(mid)) ok = mid;
        else ng = mid;
      }
      cout << ok << endl;
    }
  }
}