#include <bits/stdc++.h>
const double PI = acos(-1.0);
const double EPS = 1E-9;
const int INF = (int)1E9;
using namespace std;
int N, K;
bool v[1000005];
int a[5005];
int X, Y, D;
int lf;
int fac[20];
int fcnt[20];
int P;
int prm[1000005];
int lg[1000005];
int sumg[1000005];
int g[1000005][10];
int pref[1000005];
void gen(int t, int prd) {
  if (t == lf) {
    if (sumg[prd] > K) return;
    bool hit = 0;
    for (int i = 0; i < (lg[prd]); i++) {
      int Z = g[prd][i];
      if (X == Z) {
        hit = 1;
        sumg[prd]++;
        if (sumg[prd] > K) break;
        continue;
      }
      if ((X - Z) % prd == 0) {
        hit = 1;
        break;
      }
    }
    if (!hit) {
      g[prd][lg[prd]] = X;
      sumg[prd]++;
      lg[prd]++;
    }
    return;
  }
  gen(t + 1, prd);
  for (int i = (1); i <= (fcnt[t]); i++) {
    prd *= fac[t];
    gen(t + 1, prd);
  }
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < (N); i++) scanf("%d", &a[i]);
  sort(a, a + N);
  memset(v, 0, sizeof(v));
  memset(sumg, 0, sizeof(sumg));
  P = 0;
  for (int i = (2); i <= (1000005 - 1); i++) {
    if (v[i]) continue;
    prm[P++] = i;
    pref[i] = i;
    for (int j = (2); j <= (1000005); j++) {
      if (i * j > 1000005) {
        break;
      }
      pref[i * j] = i;
      v[i * j] = 1;
    }
  }
  memset(g, 0, sizeof(g));
  for (int i = 0; i < (N); i++) {
    X = a[i];
    for (int j = (i + 1); j <= (N - 1); j++) {
      Y = a[j];
      D = Y - X;
      if (sumg[D] > K) continue;
      int p;
      lf = 0;
      while (D > 1) {
        p = pref[D];
        fac[lf] = p;
        fcnt[lf] = 0;
        while (D % p == 0) {
          D /= p;
          fcnt[lf]++;
        }
        lf++;
      }
      gen(0, 1);
    }
  }
  for (int i = (1); i <= (1000005 - 1); i++) {
    if (sumg[i] <= K) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
