#include <bits/stdc++.h>
using namespace std;
pair<short, short> g[12497502];
int tot;
int head[1000000 + 5], nex[12497502], num[1000000 + 5];
int n, k;
int a[5005];
int vs[5005];
int sta[20], ri;
int fa[5005], al;
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  ++al;
  fa[x] = y;
}
void add(int i, int j) {
  int p = abs(a[i] - a[j]);
  g[tot] = pair<short, short>(i, j);
  ++num[p];
  nex[tot] = head[p];
  head[p] = tot++;
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    fa[i] = i;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) add(i, j);
  for (int i = n - k; i <= 1000000 + 1; ++i) {
    int sz = 0;
    ri = 0;
    al = 0;
    for (int j = 0; j <= 1000000; j += i) sz += num[j];
    if (sz > k * (k + 1) / 2) continue;
    for (int j = 0; j <= 1000000; j += i)
      for (int u = head[j]; ~u; u = nex[u]) {
        int fi = g[u].first, se = g[u].second;
        if (vs[fi] != i) {
          vs[fi] = i;
          sta[ri++] = fi;
        }
        if (vs[se] != i) {
          vs[se] = i;
          sta[ri++] = se;
        }
        unite(fi, se);
      }
    if (al <= k) {
      printf("%d\n", i);
      exit(0);
    }
    for (int j = 0; j < ri; ++j) fa[sta[j]] = sta[j];
  }
  return 0;
}
