#include <bits/stdc++.h>
using namespace std;
int sum, n, m, i, j, ans, a[1000001], v[1000001], cnt[1000001];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) cnt[abs(a[i] - a[j])]++;
  for (i = 1; i <= 1e6; i++) {
    sum = 0;
    for (j = i; j <= 1e6; j += i) sum += cnt[j];
    if (sum > (m + 1) * m / 2) continue;
    for (j = 1; j <= n; j++) {
      if (v[a[j] % i] == i) ans++;
      v[a[j] % i] = i;
    }
    if (ans <= m) {
      printf("%d", i);
      return 0;
    }
    ans = 0;
  }
}
