#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> in;
vector<int> rem[1000010];
int used[5010], ust;
void quit(int how) {
  printf("%d\n", how);
  exit(0);
}
int main() {
  scanf("%d%d", &N, &K);
  in.resize(N);
  for (int i = 0; i < N; ++i) scanf("%d", &in[i]);
  sort(in.begin(), in.end());
  for (int i = 0; i < N; ++i)
    for (int j = i + 1; j < N; ++j) {
      int val = in[j] - in[i];
      if (((int)(rem[val]).size()) <= K) rem[val].push_back(j);
    }
  int MV = in.back();
  for (int M = 1;; ++M) {
    ++ust;
    int cnt = 0;
    for (int j = M; j <= MV; j += M) {
      for (int p = 0; p < ((int)(rem[j]).size()); ++p)
        if (used[rem[j][p]] != ust) {
          ++cnt;
          used[rem[j][p]] = ust;
          if (cnt > K) goto FIN;
        }
    }
    quit(M);
  FIN:;
  }
  return 0;
}
