#include <bits/stdc++.h>
using namespace std;
int n, k, kk;
vector<int> a;
vector<int> bad, mod;
const int sz = 1000002;
inline bool check(int m) {
  int c = kk;
  for (int mm = m; mm < sz; mm += m)
    if ((c -= bad[mm]) < 0) return false;
  c = k;
  for (int i = (int)(0); i < (int)(n); ++i) {
    if (++mod[a[i] % m] > 1) {
      if (--c < 0) {
        for (int j = (int)(0); j < (int)(i + 1); ++j) mod[a[j] % m] = 0;
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin >> n >> k;
  a.resize(n);
  for (int i = (int)(0); i < (int)(n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  bad.resize(sz);
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(i + 1); j < (int)(n); ++j) ++bad[a[j] - a[i]];
  kk = k * (k + 1) / 2;
  mod.resize(sz);
  for (int i = (int)(1); i < (int)(sz); ++i) {
    if (check(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
