#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7f7f7f7f;
const int mod = 1000000007;
int a[5004], b[5004 * 200];
bool vt[5004 * 200];
int main() {
  int i, j;
  int n, k;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  memset(b, 0, sizeof(b));
  for (i = 2; i <= n; ++i) {
    for (j = 1; j < i; ++j) {
      b[a[i] - a[j]]++;
    }
  }
  for (i = n - k; i <= 1000001; ++i) {
    int cnt = 0;
    for (j = i; j <= a[n]; j += i) cnt += b[j];
    if (cnt > k * (k + 1) / 2) continue;
    memset(vt, false, sizeof(vt));
    cnt = 0;
    for (j = 1; j <= n; ++j) {
      int p = a[j] % i;
      if (!vt[p])
        vt[p] = true;
      else
        cnt++;
    }
    if (cnt <= k) break;
  }
  printf("%d\n", i);
  return 0;
}
