#include <bits/stdc++.h>
const long long inf = 9000000000000000000ll;
using namespace std;
const int d = 1000000;
int a[10000], used[3000000], v[3000000][10], kol[3000000], n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= 2000000; i++) used[i] = 0;
  for (int i = 1; i <= 2000000; i++) kol[i] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (used[d + a[i] - a[j]] != i && kol[d + a[i] - a[j]] < 5) {
        kol[d + a[i] - a[j]]++;
        v[d + a[i] - a[j]][kol[d + a[i] - a[j]]] = i;
      }
      used[d + a[i] - a[j]] = i;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 2000000; i++) used[i] = 0;
  for (int i = 1; i <= 1000001; i++) {
    int r = 0, k1 = 0;
    while (r <= 1000000) {
      for (int j = 1; j <= kol[r + d]; j++) {
        if (used[v[r + d][j]] != i) k1++;
        used[v[r + d][j]] = i;
        if (k1 > k) break;
      }
      if (k1 > k) break;
      r += i;
    }
    r = 0;
    while (r >= -1000000) {
      for (int j = 1; j <= kol[r + d]; j++) {
        if (used[v[r + d][j]] != i) k1++;
        used[v[r + d][j]] = i;
        if (k1 > k) break;
      }
      if (k1 > k) break;
      r -= i;
    }
    if (k1 <= k) {
      ans = i;
      break;
    }
  }
  cout << ans;
  return 0;
}
