#include <bits/stdc++.h>
using namespace std;
int n, a[5003], dif[1000006], k, mod[1000006], ans, x;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++) dif[a[i] - a[j]]++;
  for (int i = n - k; i <= a[n] + 1; i++) {
    for (int j = i + i; j <= a[n]; j += i) dif[i] += dif[j];
    if (dif[i] > k * (k + 1) / 2) continue;
    memset(mod, 0, sizeof(mod));
    ans = 0;
    for (int j = 1; j <= n; j++) {
      x = a[j] % i;
      mod[x]++;
      if (mod[x] > 1) ans++;
    }
    if (ans <= k) return printf("%d", i), 0;
  }
}
