#include <bits/stdc++.h>
using namespace std;
const long long int mx = 5e3 + 1, Mod = 1e9 + 7, M = 1e6 + 2;
int n, k, a[mx];
vector<int> dif[M];
int num[M];
int etov[mx * mx];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) etov[i * (i - 1) / 2] = i;
  sort(a, a + n);
  for (int i = 0; i < M; i++) dif[i].reserve(9);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      if (dif[a[i] - a[j]].size() <= 8) dif[a[i] - a[j]].push_back(a[i]);
  int del;
  for (int ans = max(n - k, 1); ans < M; ans++) {
    del = 0;
    for (int i = ans; i < M && !del; i += ans)
      if (dif[i].size() > 8) del = k + 1;
    if (del > k) continue;
    for (int i = ans; i < M; i += ans)
      for (int j = 0; j < dif[i].size(); j++) num[dif[i][j] % ans]++;
    for (int i = ans; i < M; i += ans)
      for (int j = 0; j < dif[i].size(); j++)
        if (num[dif[i][j] % ans]) {
          del += etov[num[dif[i][j] % ans]] - 1;
          num[dif[i][j] % ans] = 0;
        }
    if (del <= k) return cout << ans << '\n', 0;
  }
  return 0;
}
