#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int num[1000005];
int vis[1000005];
int main() {
  int i, j, n, maxn, k;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  memset(num, 0, sizeof(num));
  maxn = 0;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      num[abs(a[i] - a[j])]++;
      maxn = max(maxn, abs(a[i] - a[j]));
    }
  }
  for (i = 1; i <= maxn; i++) {
    for (j = i * 2; j <= maxn; j += i) {
      num[i] += num[j];
    }
  }
  for (i = 1; i <= maxn; i++) {
    if (num[i] > k * (k + 1) / 2) continue;
    if (num[i] <= k) {
      printf("%d\n", i);
      break;
    }
    memset(vis, 0, sizeof(vis));
    int cnt = 0;
    for (j = 0; j < n; j++) {
      if (vis[a[j] % i] == 1)
        cnt++;
      else
        vis[a[j] % i]++;
      if (cnt > k) break;
    }
    if (j == n) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
