#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int size(const T& c) {
  return c.size();
}
using namespace std;
const int maxn = 5000 + 10;
const int maxd = 1000000 + 10;
int a[maxn];
int cnt[maxd];
int diff[maxd];
int tick[maxd];
vector<int> p[maxd];
int n, k;
int main() {
  cin >> n >> k;
  for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];
  for (int i = (1), _b = (n); i <= _b; i++)
    for (int j = (i + 1), _b = (n); j <= _b; j++) diff[abs(a[i] - a[j])]++;
  for (int i = (1), _b = (1000001); i <= _b; i++) {
    int cnt = 0;
    for (int j = i; j <= 1000001; j += i) cnt += diff[j];
    if (cnt > (k + 1) * k / 2) continue;
    int res = 0;
    for (int j = (1), _b = (n); j <= _b; j++) {
      if (tick[a[j] % i] != i)
        tick[a[j] % i] = i;
      else
        res++;
    }
    if (res <= k) {
      cout << i;
      return 0;
    }
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
