#include <bits/stdc++.h>
using namespace std;
int n, k, a[5005];
vector<int> v, cnt, d[1000005];
int findr(int i) {
  if (v[i] == i) return i;
  return v[i] = findr(v[i]);
}
void connect(int i, int j) { v[findr(i)] = findr(j); }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int diff = a[j] - a[i];
      if (d[diff].size() <= k) d[diff].push_back(a[i]);
    }
  int M = a[n - 1] + 1, m;
  for (m = 1;; m++) {
    bool ok = true;
    int s = 0;
    for (int j = m; j <= M; j += m) {
      if (d[j].size() > k) {
        ok = false;
        break;
      }
      s += d[j].size();
    }
    if (ok && (s <= k * (k + 1) / 2)) {
      map<int, int> p;
      int c = 0;
      for (int j = m; j <= M; j += m)
        for (int i = 0; i < d[j].size(); i++) {
          int a = d[j][i], b = d[j][i] + j;
          if (!p.count(a)) p[a] = c++;
          if (!p.count(b)) p[b] = c++;
        }
      v.clear();
      cnt.clear();
      for (int i = 0; i < c; i++) {
        v.push_back(i);
        cnt.push_back(0);
      }
      for (int j = m; j <= M; j += m)
        for (int i = 0; i < d[j].size(); i++) {
          int a = d[j][i], b = d[j][i] + j;
          connect(p[a], p[b]);
        }
      for (int i = 0; i < c; i++) cnt[findr(i)]++;
      int ans = 0;
      for (int i = 0; i < c; i++) ans += max(cnt[i] - 1, 0);
      if (ans <= k) break;
    }
  }
  printf("%d\n", m);
  return 0;
}
