#include <bits/stdc++.h>
using namespace std;
const int intmax = 0x3f3f3f3f;
const long long lldmax = 0x3f3f3f3f3f3f3f3fll;
double eps = 1e-8;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T lowbit(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T checkmod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T euclid(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclid(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclid(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclid(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
template <class T>
inline int dblcmp(T a, const T b) {
  a -= b;
  return a > eps ? 1 : (a < -eps ? -1 : 0);
}
template <class T>
inline int sgn(T a) {
  return a > eps ? 1 : (a < -eps ? -1 : 0);
}
const int N = 1100000;
long long a[N], cnt[N];
long long ch[N];
int n, k;
bool check(int m) {
  for (int i = 0; i < m; ++i) ch[i] = 0;
  long long del = k;
  for (int i = 0; i < n; ++i) {
    ch[a[i] % m]++;
    long long tmp = ch[a[i] % m];
    if (tmp > 1) del--;
    if (del < 0) break;
  }
  return del >= 0;
}
int main() {
  cin >> n >> k;
  if (n <= k + 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      cnt[a[j] - a[i]]++;
    }
  }
  long long ans = N;
  for (int i = 1; i < N; ++i) {
    int tmp = 0;
    for (int j = i; j < N; j += i) {
      tmp += cnt[j];
    }
    if (tmp <= k * (k + 1) / 2 && check(i)) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
