#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const int maxn = 1000005;
int u[maxn], w[maxn], a[5005], k, n;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++) w[a[i] - a[j]]++;
  for (int ans = 1; ans <= a[n] + 1; ans++) {
    int cnt = 0;
    for (int j = ans; j <= a[n]; j += ans) cnt += w[j];
    if (cnt > k * (k + 1) / 2) continue;
    cnt = 0;
    for (int j = 1; j <= n; j++) {
      int x = a[j] % ans;
      if (u[x] == ans) cnt++;
      u[x] = ans;
    }
    if (cnt <= k) {
      printf("%d\n", ans);
      break;
    }
  }
  return 0;
}
