#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000 + 10;
const int MAXOMEGA = 1e6 + 10;
int N, K, mxval, arr[MAXN], blocksize[MAXOMEGA];
vector<int> rec[MAXOMEGA];
bool vis[MAXOMEGA];
int main() {
  scanf("%d %d", &N, &K);
  int LIM = K * (K + 1) / 2;
  for (int i = (0), iend = (N); i < iend; ++i)
    scanf("%d", &arr[i]), mxval = max(mxval, arr[i]);
  sort(arr, arr + N);
  for (int i = (0), iend = (N); i < iend; ++i)
    for (int j = (0), jend = (i); j < jend; ++j) {
      int del = arr[i] - arr[j];
      if ((int)rec[del].size() > LIM) continue;
      rec[del].push_back(i * N + j);
    }
  for (int ans = (1), ansend = (mxval + 1); ans < ansend; ++ans) {
    int tot = 0, cst = 0;
    bool ok = true;
    vector<int> recover;
    for (int i = ans; i < mxval; i += ans) {
      tot += rec[i].size();
      if (tot > LIM) {
        ok = false;
        break;
      }
      for (int& pp : rec[i]) {
        int u = pp / N, v = pp % N;
        if (!vis[arr[u]]) {
          vis[arr[u]] = true, recover.push_back(arr[u]);
          if (blocksize[arr[u] % ans]++) cst++;
        }
        if (!vis[arr[v]]) {
          vis[arr[v]] = true, recover.push_back(arr[v]);
          if (blocksize[arr[v] % ans]++) cst++;
        }
        if (cst > K) {
          ok = false;
          break;
        }
      }
    }
    if (!ok) {
      for (int ii : recover) blocksize[ii % ans] = 0, vis[ii] = false;
      continue;
    }
    return printf("%d\n", ans), 0;
  }
  return 0;
}
