#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int M = 1e6 + 1;
int a[N], cnt[M], vis[N];
int Abs(int x) { return x < 0 ? -x : x; }
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    memset(cnt, 0, sizeof(cnt));
    int Max = 0, i;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (Max < a[i]) Max = a[i];
    }
    for (i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) cnt[Abs(a[i] - a[j])]++;
    }
    for (i = 1; i <= M; i++) {
      int num = 0;
      for (int j = i; j <= Max; j += i) num += cnt[j];
      if (num > k * (k + 1) / 2) continue;
      num = 0;
      for (int j = 1; j <= n; j++) {
        if (vis[a[j] % i] == i)
          num++;
        else
          vis[a[j] % i] = i;
      }
      if (num <= k) break;
    }
    printf("%d\n", i);
  }
  return 0;
}
