#include <bits/stdc++.h>
using namespace std;
template <class my>
my aabs(const my &a) {
  return (a > 0) ? a : -a;
}
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
long long int LSOne(long long int k) { return (k & (-k)); }
inline int inv(int o) {
  int b = 1000000007, u = 0, v = 1, t, a = o;
  while (a) {
    t = b / a;
    b -= t * a;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  if (u < 0) u += 1000000007;
  return u;
}
inline int add(const int &a, const int &b) {
  return a + b >= 1000000007 ? a + b - 1000000007 : a + b;
}
inline int sub(const int &a, const int &b) {
  return a - b < 0 ? a - b + 1000000007 : a - b;
}
inline int mul(const int &a, const int &b) {
  return int(a * 1ll * b % 1000000007);
}
inline int _div(const int &a, const int &b) { return mul(a, inv(b)); }
inline int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    b >>= 1;
  }
  return ans;
}
vector<int> diff[1000005];
bool taken[1000005];
bool used[1000005];
void solve() {
  int n, k, temp;
  cin >> n >> k;
  int arr[n + 5];
  for (int i = 0; i < n; i++) cin >> arr[i];
  if ((n - 1) <= k) {
    cout << 1 << "\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      temp = aabs(arr[i] - arr[j]);
      if (diff[temp].size() <= 2 * k) {
        diff[temp].push_back(arr[i]);
        diff[temp].push_back(arr[j]);
      }
    }
  }
  for (int i = 2; i < 1000002; i++) {
    vector<int> val;
    int rem = 0;
    for (int u = 0; u < 1000001; u += i) {
      if (diff[u].size() > 2 * k) {
        rem = k + 1;
        break;
      }
      for (__typeof(diff[u].begin()) x = (diff[u].begin());
           x != (diff[u].end()); ++x) {
        if (used[*x]) continue;
        temp = *x % i;
        if (taken[temp])
          rem++;
        else
          taken[temp] = true;
        used[*x] = true;
        val.push_back(*x);
      }
      if (rem > k) break;
    }
    if (rem <= k) {
      cout << i << "\n";
      return;
    }
    for (__typeof(val.begin()) x = (val.begin()); x != (val.end()); ++x) {
      used[*x] = false;
      taken[*x % i] = false;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) solve();
}
