#include <bits/stdc++.h>
using namespace std;
int n, K, a[1000010], diff[1000010], tot, maxn;
int flag[1000010];
void Init() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    maxn = max(maxn, a[i]);
  }
}
void solve() {
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) diff[a[j] - a[i]]++;
  int ans;
  for (ans = 1;; ++ans) {
    int ff = 0;
    for (int i = ans; i < maxn; i += ans) ff += diff[i];
    if (ff > (K * (K + 1) >> 1)) continue;
    tot = 0;
    for (int i = 1; i <= n; i++) {
      if (flag[a[i] % ans] == ans) tot++;
      flag[a[i] % ans] = ans;
    }
    if (tot <= K) break;
  }
  printf("%d\n", ans);
}
int main() {
  Init();
  solve();
  return 0;
}
