#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1e6;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &ai : a) cin >> ai;
  sort(begin(a), end(a));
  vector<int> cnt_d(MAX + 1);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++) {
      cnt_d[a[i] - a[j]]++;
    }
  vector<int> cnt(MAX + 1);
  auto check = [&](int m) {
    int sum = 0, lim = k * (k + 1) / 2;
    for (int i = m; i <= MAX; i += m) {
      if ((sum += cnt_d[i]) > lim) return false;
    }
    int dup = 0;
    cnt.assign(m, 0);
    for (int ai : a)
      if (cnt[ai % m]++ && ++dup > k) return false;
    return true;
  };
  int mod = 1;
  while (!check(mod)) mod++;
  cout << mod << endl;
  return 0;
}
