#include <bits/stdc++.h>
using namespace std;
int n, k, a[5001], b[1000001], d[1000001];
void doc() {
  for (int i = 1; i <= n; i++) cin >> a[i];
}
void xuli() {
  sort(a + 1, a + n + 1);
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) d[a[j] - a[i]]++;
  int m = 0;
  while (true) {
    m++;
    int dem = 0, res = 0;
    for (int j = m; j <= 1000001; j += m) dem += d[j];
    if (dem > (k * (k + 1)) / 2) continue;
    for (int i = 1; i <= n; i++) {
      if (b[a[i] % m] == m) res++;
      b[a[i] % m] = m;
    }
    if (res <= k) break;
  }
  cout << m;
}
int main() {
  cin >> n >> k;
  doc();
  xuli();
}
