#include <bits/stdc++.h>
using namespace std;
int b[1200000], c[1200000], g[10000];
int i, j, m, n, r, t;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &g[i]);
  sort(g + 1, g + n + 1);
  for (i = 1; i < n; i++)
    for (j = i + 1; j <= n; j++) b[g[j] - g[i]]++;
  for (i = 1; i <= 1000000; i++) {
    t = 0;
    for (j = i; j <= 1000000; j = j + i) t = t + b[j];
    if (t > m * (m + 1) / 2) continue;
    t = 0;
    for (j = 1; j <= n; j++)
      if (c[g[j] % i] != i)
        c[g[j] % i] = i;
      else
        t++;
    if (t <= m) break;
  }
  printf("%d", i);
  return 0;
}
