#include <bits/stdc++.h>
using namespace std;
int n, k, tmp, cnt, ans;
int diff[1000001 + 10], a[10000], b[1000001 + 10];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) diff[a[j] - a[i]]++;
  for (int i = 1; i <= 1000001; i++) {
    tmp = cnt = 0;
    for (int j = i; j <= 1000001; j += i) cnt += diff[j];
    if (cnt > ((k + 1) * k >> 1)) continue;
    for (int j = 0; j < n; j++) {
      if (b[a[j] % i] == i) tmp++;
      b[a[j] % i] = i;
    }
    ans = i;
    if (k >= tmp) break;
  }
  printf("%d\n", ans);
  return 0;
}
