#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
int f[N], a[N], k;
bool check(int n, int m) {
  unordered_set<int> b;
  int del = 0;
  for (int i = 1; i <= n && del <= k; ++i) {
    if (b.count(a[i] % m))
      ++del;
    else
      b.insert(a[i] % m);
  }
  return del <= k;
}
int main() {
  int n, maxDiff = 0;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    for (int j = 1; j < i; ++j) {
      int d = a[j] - a[i];
      if (d < 0) d = -d;
      f[d]++;
      maxDiff = max(maxDiff, d);
    }
  }
  if (n == 1) {
    puts("1");
    return 0;
  }
  for (int i = 1; i < maxDiff; ++i) {
    int count = 0;
    bool ok = true;
    for (int j = i; j <= maxDiff; j += i) {
      count += f[j];
      if (count * 2 > k * (k + 1)) {
        ok = 0;
        break;
      }
    }
    if (!ok) continue;
    if (count <= k) {
      printf("%d", i);
      return 0;
    }
    if (check(n, i)) {
      printf("%d", i);
      return 0;
    }
  }
  return 0;
}
