#include <bits/stdc++.h>
using namespace std;
pair<int, int> edge[13000001];
int beg[1000001], ed[1000001], nx[13000001], p, sz[1000001];
int n, k, s[5005], par[5005];
int f(int x) { return par[x] == x ? x : par[x] = f(par[x]); }
int involve[5005], pp, lis[5005];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = (1); i <= (n); i++) scanf("%d", &s[i]);
  sort(s + 1, s + n + 1);
  memset(ed, -1, sizeof(ed));
  for (int i = (1); i <= (n); i++)
    for (int j = (i + 1); j <= (n); j++) {
      int diff = s[j] - s[i];
      edge[++p] = make_pair(i, j);
      if (ed[diff] == -1)
        beg[diff] = ed[diff] = p;
      else {
        nx[ed[diff]] = p;
        ed[diff] = p;
      }
      nx[p] = -1;
      sz[diff]++;
    }
  for (int i = (1); i <= (n); i++) par[i] = i;
  for (int i = (1); i <= (1000001); i++) {
    int cnt = 0;
    for (int j = i; j <= 1000000; j += i) {
      cnt += sz[j];
      if (cnt > k * (k + 1) / 2) goto gg;
    }
    pp = cnt = 0;
    for (int j = i; j <= 1000000; j += i) {
      if (beg[j] != 0) {
        for (int id = beg[j]; id != -1; id = nx[id]) {
          int pa = f(edge[id].first), pb = f(edge[id].second);
          if (pa == pb) continue;
          par[pa] = pb;
          if (!involve[pa]) {
            involve[pa] = true;
            lis[++pp] = pa;
          }
          cnt++;
          if (cnt > k) goto gg;
        }
      }
    }
    printf("%d\n", i);
    return 0;
  gg:;
    for (int j = (1); j <= (pp); j++) {
      involve[lis[j]] = false;
      par[lis[j]] = lis[j];
    }
  }
}
