#include <bits/stdc++.h>
using namespace std;
int f[5500];
bool r[1001000];
int x[1001000];
int ff[5] = {0, 1, 3, 6, 10};
int tmp;
int n, K;
bool check(int i) {
  tmp = 0;
  for (int k = i; k <= f[n]; k += i) {
    tmp += x[k];
    if (tmp > ff[K]) return false;
  }
  tmp = 0;
  memset(r, 0, sizeof(r));
  for (int k = 1; k <= n; k++) {
    tmp += (int)r[f[k] % i];
    r[f[k] % i] = true;
    if (tmp > K) return false;
  }
  return true;
}
int main() {
  while (~scanf("%d%d", &n, &K)) {
    memset(x, 0, sizeof(x));
    for (int i = 1; i <= n; i++) scanf("%d", &f[i]);
    sort(f + 1, f + n + 1);
    for (int i = 1; i < n; i++)
      for (int j = i + 1; j <= n; j++) {
        x[f[j] - f[i]]++;
      }
    for (int i = 1;; i++) {
      if (check(i)) {
        printf("%d\n", i);
        break;
      }
    }
  }
  return 0;
}
