#include <bits/stdc++.h>
using namespace std;
int n, k, a;
vector<int> v, ck;
vector<int> has(1000002, 0);
bool check(int x) {
  for (int i = 0; i < x; ++i) {
    ck[i] = 0;
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int d = v[i] % x;
    if (ck[d]) res++;
    ck[d]++;
  }
  return res <= k;
}
int del(int x) {
  if (x < 0) x = -x;
  has[x]++;
}
int main() {
  cin >> n >> k;
  v.resize(n + 2, 0);
  ck.resize(1000000, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a;
    v[i] = a;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int d = abs(v[i] - v[j]);
      has[d]++;
    }
  }
  for (int i = n - k; i < 1000000; ++i) {
    int s = 0;
    for (int x = i; x < 1000000; x += i) {
      s += has[x];
    }
    if (s <= (k * (k + 1) / 2) && check(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
