#include <bits/stdc++.h>
using namespace std;
const int INF = 1E9 + 7;
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  out << "(" << pair.first << ", " << pair.second << ")";
  return out;
}
vector<int> kto[1000005];
int t[1000005];
int K;
const int CHUJ = 10;
void dodaj(vector<int>& d, int k) {
  if (((int)(d).size()) >= CHUJ) return;
  for (__typeof((d).begin()) it = ((d).begin()); it != (d).end(); ++it) {
    if (*it == k) return;
  }
  d.push_back(k);
}
bool done[CHUJ + 1];
bool jest[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n >> K;
  for (int i = (1); i <= (n); ++i) cin >> t[i];
  for (int i = (1); i <= (1000005 - 1); ++i) kto[i].reserve(10);
  for (int i = (1); i <= (n); ++i)
    for (int j = (i + 1); j <= (n); ++j) {
      dodaj(kto[abs(t[i] - t[j])], i);
      dodaj(kto[abs(t[i] - t[j])], j);
    }
  vector<int> rr;
  rr.reserve(10);
  for (int i = (1); i <= (1000005 - 1); ++i) {
    rr.clear();
    int w = 1;
    while (w * i < 1000005) {
      for (__typeof((kto[w * i]).begin()) it = ((kto[w * i]).begin());
           it != (kto[w * i]).end(); ++it) {
        if (((int)(rr).size()) >= CHUJ) break;
        if (!jest[*it]) {
          jest[*it] = 1;
          rr.push_back(*it);
        }
      }
      if (((int)(rr).size()) >= CHUJ) break;
      ++w;
    }
    memset((done), 0, sizeof(done));
    int torem = 0;
    if (((int)(rr).size()) >= CHUJ) {
      for (__typeof((rr).begin()) it = ((rr).begin()); it != (rr).end(); ++it) {
        jest[*it] = 0;
      }
      continue;
    }
    for (int a = (0); a <= (((int)(rr).size()) - 1); ++a) {
      if (done[a]) continue;
      int s = 1;
      for (int b = (a + 1); b <= (((int)(rr).size()) - 1); ++b) {
        if ((t[rr[a]] - t[rr[b]]) % i == 0) {
          done[b] = 1;
          ++s;
        }
      }
      torem += s - 1;
      if (torem > K) break;
    }
    for (__typeof((rr).begin()) it = ((rr).begin()); it != (rr).end(); ++it) {
      jest[*it] = 0;
    }
    if (torem <= K) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
