#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long bad[1000005];
long long cnt[1000005];
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  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++) {
      bad[a[j] - a[i]]++;
    }
  }
  bool found = false;
  for (int i = 1;; i++) {
    found = false;
    long long ans = 0;
    for (int j = i; j < 1000005; j += i) ans += bad[j];
    if (ans > (k * (k + 1) / 2)) continue;
    long long cnt1 = 0;
    long long pos;
    for (int j = 0; j < n; j++) {
      if (cnt[a[j] % i] != 0) cnt1++;
      cnt[a[j] % i]++;
      pos = j;
      if (cnt1 > k) {
        found = true;
        break;
      }
    }
    for (int j = 0; j <= pos; j++) cnt[a[j] % i]--;
    if (!found) {
      cout << i;
      return 0;
    }
  }
}
