#include <bits/stdc++.h>
using namespace std;
const int N = 5555;
const int MOD = 1111111;
int a[N];
int calc[MOD];
bool mark[MOD];
int mov[5] = {0, 1, 3, 6, 10};
int n;
int check(int m) {
  int ret = 0;
  for (int i = 0; i < m; i++) mark[i] = 0;
  for (int i = 1; i <= n; i++)
    if (!mark[a[i] % m])
      mark[a[i] % m] = 1;
    else
      ret++;
  return ret;
}
int main() {
  int k, t, m, i, j;
  while (cin >> n >> k) {
    for (i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    memset(calc, 0, sizeof(calc));
    for (i = 1; i <= n; i++)
      for (j = i + 1; j <= n; j++) calc[a[j] - a[i]]++;
    for (i = 1; i < MOD; i++) {
      t = 0;
      for (j = i; j < MOD; j += i) {
        t += calc[j];
        if (t > mov[k]) break;
      }
      if (t <= mov[k] && check(i) <= k) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
