#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
bool vis[N];
int n, k;
int a[5010];
int d[N], b[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < i; ++j) {
      int t = a[i] - a[j];
      if (t < 0) t = -t;
      vis[t] = true;
      d[t]++;
    }
  int ans = 0;
  while (++ans) {
    int i = 0, ct = 0;
    while ((++i) * ans < N && ct <= k * k) ct += d[i * ans];
    if (ct < k * k) {
      ct = 0;
      for (int j = 0; j < n; ++j) {
        if (b[a[j] % ans] == ans) ct++;
        b[a[j] % ans] = ans;
      }
    }
    if (ct <= k) break;
  }
  printf("%d\n", ans);
  return 0;
}
