#include <bits/stdc++.h>
using namespace std;
int a[10000];
bool c[1000001];
int use[1000001];
int k, n;
int need[1000001];
bool chack(int i) {
  memset(c, 0, sizeof(c));
  int tot = 0;
  for (int j = 0; j < n; j++) {
    int u = a[j] % i;
    if (c[u]) tot++;
    c[u] = 1;
  }
  if (tot <= k) return 1;
  return 0;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) use[abs(a[i] - a[j])]++;
  for (int i = 1; i < 1000001; i++)
    for (int j = 1; j * i < 1000001; j++) need[i] += use[j * i];
  int i = 1;
  for (i = 1; i < 1000001; i++)
    if (need[i] <= k * (k + 1) / 2)
      if (chack(i)) break;
  cout << i << endl;
  return 0;
}
