#include <bits/stdc++.h>
using namespace std;
struct para {
  int a, b;
};
vector<int> Z;
void Stworz(int n) {
  for (int i = 0; i < n; ++i) Z.push_back(i);
}
int Find(int a) {
  if (Z[a] == a) return a;
  int fa = Find(Z[a]);
  Z[a] = fa;
  return fa;
}
int Union(int a, int b) {
  int fa = Find(a);
  int fb = Find(b);
  if (fa != fb) {
    Z[fa] = fb;
    return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  vector<vector<para> > pary(1000001);
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j > i; --j) {
      int r = a[j] - a[i];
      if (r < n - k) break;
      if (pary[r].size() <= 5) pary[r].push_back({i, j});
    }
  }
  Stworz(n);
  vector<bool> jest(1000001, false);
  for (int i = max(1, n - k); i <= 1000000; ++i) {
    vector<int> rozne;
    bool ok = true;
    for (int j = i; j <= 1000000; j += i) {
      if (pary[j].size() > 5) {
        ok = false;
        break;
      }
      for (int l = 0; l < pary[j].size(); ++l) {
        if (!jest[pary[j][l].a]) {
          rozne.push_back(pary[j][l].a);
          jest[pary[j][l].a] = true;
        }
        if (!jest[pary[j][l].b]) {
          rozne.push_back(pary[j][l].b);
          jest[pary[j][l].b] = true;
        }
      }
      if (rozne.size() > 8) {
        ok = false;
        break;
      }
    }
    if (!ok) {
      for (int j = 0; j < rozne.size(); ++j) {
        Z[rozne[j]] = rozne[j];
        jest[rozne[j]] = false;
      }
      continue;
    }
    int spojne = rozne.size();
    for (int j = i; j <= 1000000; j += i)
      for (int l = 0; l < pary[j].size(); ++l)
        spojne -= Union(pary[j][l].a, pary[j][l].b);
    if (rozne.size() - spojne <= k) {
      cout << i;
      return 0;
    }
    for (int j = 0; j < rozne.size(); ++j) {
      Z[rozne[j]] = rozne[j];
      jest[rozne[j]] = false;
    }
  }
}
