#include <bits/stdc++.h>
using namespace std;
int mx, n, m, sum, hh, la, v[1000001], a[100001], sz[1000010], tot, e[10000001],
    nt[10000001], hd[1000010];
void build(int x, int y) {
  tot++;
  e[tot] = y;
  nt[tot] = hd[x];
  hd[x] = tot;
}
int main() {
  int i, j, k;
  mx = 1e6;
  scanf("%d%d", &n, &m);
  la = m;
  m = m * (m + 1) / 2;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j < i; j++) sz[a[i] - a[j]]++;
  for (i = 1; i <= n; i++)
    for (j = 1; j < i; j++)
      if (sz[a[i] - a[j]] <= m) build(a[i] - a[j], a[j]);
  for (i = 1; i <= mx + 1; i++) {
    sum = 0;
    for (j = i; j <= mx + 1; j += i) sum += sz[j];
    if (sum > m) continue;
    for (j = i; j <= mx + 1; j += i)
      for (k = hd[j]; k; k = nt[k])
        if (v[e[k]] != i) {
          v[e[k]] = i;
          hh++;
        }
    if (hh <= la) return printf("%d", i), 0;
    hh = 0;
  }
}
