#include <bits/stdc++.h>
using namespace std;
long n, k, bd, s, ar[6000], ans, calc[1200000];
long lst[1200000];
long del;
long q;
void check(long mod) {
  del = 0;
  for (int i = 1; i <= n; i++) {
    q = ar[i] % mod;
    if (lst[q] == mod)
      ++del;
    else
      lst[q] = mod;
    if (del > k) break;
  }
  if (del <= k) ans = mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  if (k == 0) bd = 0;
  if (k == 1) bd = 1;
  if (k == 2) bd = 3;
  if (k == 3) bd = 6;
  if (k == 4) bd = 10;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  sort(ar + 1, ar + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) calc[ar[j] - ar[i]]++;
  ans = 0;
  for (int mod = 1; mod <= 1000001; mod++) {
    s = 0;
    if (ans > 0) break;
    for (int p = mod; p <= 1000001; p += mod) {
      s += calc[p];
      if (s > bd) break;
    }
    if (s <= bd) check(mod);
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
