#include <bits/stdc++.h>
using namespace std;
const int MAXM = 1000000, MAXN = 5000;
int a[MAXN + 10];
int cnt[MAXM + 10];
vector<pair<short, short> > kto[MAXM + 10];
int main(void) {
  int n, K;
  scanf("%d%d", &n, &K);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = (i + 1); j < (n); ++j) {
      int b = abs(a[i] - a[j]);
      ++cnt[b];
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = (i + 1); j < (n); ++j) {
      int b = abs(a[i] - a[j]);
      if (cnt[b] <= 10) {
        kto[b].push_back(make_pair(i, j));
      }
    }
  }
  for (int m = 1; m <= MAXM + 1; ++m) {
    int sum = 0;
    for (int j = m; j <= MAXM; j += m) {
      sum += cnt[j];
    }
    if (sum > 10) {
      continue;
    }
    vector<int> V;
    for (int j = m; j <= MAXM; j += m) {
      for (__typeof((kto[j]).begin()) it = (kto[j]).begin();
           it != (kto[j]).end(); ++it) {
        V.push_back(a[it->first]);
        V.push_back(a[it->second]);
      }
    }
    sort((V).begin(), (V).end());
    V.erase(unique((V).begin(), (V).end()), V.end());
    vector<int> vis(((int)((V).size())));
    int skl = 0;
    for (int i = 0; i < (((int)((V).size()))); ++i) {
      if (vis[i]) {
        continue;
      }
      ++skl;
      for (int j = 0; j < (((int)((V).size()))); ++j) {
        if ((V[i] - V[j]) % m == 0) {
          vis[j] = 1;
        }
      }
    }
    if (((int)((V).size())) - skl <= K) {
      printf("%d\n", m);
      return 0;
    }
  }
  return 0;
}
