#include <bits/stdc++.h>
using namespace std;
long n, m, k, i, j, t, tt, tag, Max, a[5100], h[1100000], p[1100000];
bool check(long m) {
  for (long i = 1, ans = 0; i <= n; i++) {
    tt = a[i] % m;
    if (p[tt] == m) {
      ans++;
      if (ans > k) return false;
    }
    p[tt] = m;
  }
  return true;
}
int main() {
  scanf("%ld%ld", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%ld", &a[i]);
    Max = max(Max, a[i]);
  }
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) h[(a[i] > a[j]) ? a[i] - a[j] : a[j] - a[i]]++;
  tag = (k + 1) * k / 2;
  for (m = max(1l, n - k); m <= Max; m++) {
    for (t = 0, j = m; j <= Max; j += m) {
      t += h[j];
      if (t > tag) break;
    }
    if (t <= tag)
      if (check(m)) break;
  }
  printf("%ld\n", m);
  return 0;
}
