#include <bits/stdc++.h>
using namespace std;
int cnt[1000100];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int mx = a[n - 1];
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) cnt[a[j] - a[i]]++;
  int kk = (k * (k + 1)) / 2;
  for (int i = 1; i <= mx + 1; i++) {
    int sum = 0;
    for (int j = i; j <= mx; j += i) {
      sum += cnt[j];
      if (sum > kk) break;
    }
    if (sum > kk) continue;
    map<int, int> m;
    int flag = 0, res = 0;
    for (int j = 0; j < n; j++) {
      int modular = a[j] % i;
      m[modular]++;
      if (m[modular] > 1) res++;
      if (res > k) break;
    }
    if (res <= k) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}
