#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000;
const int MAXM = 1000000;
int N, K;
int arr[MAXN + 5];
int must_remove;
int Parent[MAXM + 5];
int sz[MAXM + 5];
int h[MAXM + 5];
vector<int> joined;
vector<int> keys;
void Init() {
  for (int i = 0; i <= MAXM; i++) {
    Parent[i] = i;
    sz[i] = 1;
    h[i] = 1;
  }
}
int Find(int i) {
  if (Parent[i] == i) return i;
  return Parent[i] = Find(Parent[i]);
}
void Join(int x, int y) {
  int e1 = Find(x);
  int e2 = Find(y);
  if (e1 == e2) return;
  joined.push_back(x);
  joined.push_back(y);
  keys.push_back(e1);
  keys.push_back(e2);
  must_remove -= (sz[e1] - 1);
  must_remove -= (sz[e2] - 1);
  if (h[e1] < h[e2]) swap(e1, e2);
  if (h[e1] > h[e2]) {
    Parent[e2] = e1;
    sz[e1] += sz[e2];
  } else if (h[e1] == h[e2]) {
    Parent[e2] = e1;
    h[e1]++;
    sz[e1] += sz[e2];
  }
  must_remove += (sz[e1] - 1);
}
void Disjoin() {
  for (int i = 0; i < (int)joined.size(); i++) {
    Parent[joined[i]] = joined[i];
  }
  joined.clear();
  for (int i = 0; i < (int)keys.size(); i++) {
    sz[keys[i]] = 1;
    h[keys[i]] = 1;
  }
  keys.clear();
}
struct node {
  int x, y;
  node *next;
};
int head[MAXM + 10], nxt[MAXN * (MAXN + 1) / 2 + 10], lst = 1;
pair<int, int> to[MAXN * (MAXN + 1) / 2 + 10];
void addedge(int f, pair<int, int> t) {
  nxt[lst] = head[f];
  head[f] = lst;
  to[lst++] = t;
}
int main() {
  scanf("%d%d", &N, &K);
  int mx = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
    mx = max(mx, arr[i]);
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int d = abs(arr[i] - arr[j]);
      addedge(d, make_pair(arr[i], arr[j]));
    }
  }
  Init();
  for (int i = 1; i <= mx + 1; i++) {
    must_remove = 0;
    for (int j = i; j <= mx; j += i) {
      for (int k = head[j]; k; k = nxt[k]) {
        Join(to[k].first, to[k].second);
        if (must_remove > K) goto next_m;
      }
    }
    printf("%d\n", i);
    return 0;
  next_m:
    Disjoin();
  }
}
