#include <bits/stdc++.h>
using namespace std;
const int N = 5002;
int n, a[N], k, b[1000002], dd[1000001];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i(1); i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i(1); i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int x = a[j] - a[i];
      b[x]++;
    }
  for (int i = n - k;; i++) {
    int cur = 0;
    for (int j = i; j <= 1000000; j += i) {
      cur = cur + b[j];
    }
    if (cur * 2 > (k) * (k + 1)) continue;
    int res = 0;
    for (int j(1); j <= n; j++) {
      if (dd[a[j] % i] != i)
        dd[a[j] % i] = i;
      else
        res++;
    }
    if (res <= k) {
      cout << i;
      break;
    }
  }
}
