#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10, MOD = 1000 * 1000 * 1000 + 7;
array<int, maxn> a, diff;
array<bool, maxn> bl;
int main() {
  int n, k, i, j;
  while (cin >> n >> k) {
    for (i = 0; i < n; i++) cin >> a[i];
    diff.fill(0);
    sort(a.rbegin(), a.rend());
    for (i = 0; i < n; i++)
      for (j = i + 1; j < n; j++) diff[a[i] - a[j]]++;
    int temp, m;
    for (m = 1; m < maxn; m++) {
      temp = 0;
      cerr << "Googoooo :D" << m << endl;
      for (i = m; i < maxn; i += m) temp += diff[i];
      if (temp <= k * (k + 1) / 2) {
        bl.fill(false);
        temp = 0;
        for (j = 0; j < n && temp <= k; j++) {
          if (bl[a[j] % m])
            temp++;
          else
            bl[a[j] % m] = true;
        }
        if (temp <= k) {
          cout << m << endl;
          break;
        }
      }
    }
  }
  return 0;
}
