#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, K, diff[N], vis[N];
int main() {
  cin >> n >> K;
  vector<int> a(n, 0);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  for (int i = 0; i < (n); ++i)
    for (int j = i + 1; j < (n); ++j) diff[a[j] - a[i]]++;
  for (int i = 1; i < (N); ++i) {
    int cnt = 0;
    for (int j = i; j < N; j += i) cnt += diff[j];
    if (cnt > K * (K + 1) / 2) continue;
    int err = 0;
    for (int j = 0; j < (n); ++j) {
      err += vis[a[j] % i] == i;
      vis[a[j] % i] = i;
    }
    if (err <= K) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
