#include <bits/stdc++.h>
using namespace std;
int n, szq, a[100005], f[1000005], mx = 1, mod[1000005], ans;
int main() {
  scanf("%d%d", &n, &szq);
  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++) {
      f[a[i] - a[j]]++;
      if (a[i] - a[j] > mx) mx = a[i] - a[j];
    }
  for (int i = 1; i <= mx; i++) {
    int tot = 0, cnt = 0;
    for (int j = i; j <= mx; j += i) tot += f[j];
    if (tot > szq * (szq + 1) / 2) continue;
    for (int j = 1; j <= n; j++) {
      if (mod[a[j] % i] == i) cnt++;
      mod[a[j] % i] = i;
    }
    if (cnt > szq) continue;
    ans = i;
    break;
  }
  printf("%d", ans);
  return 0;
}
