#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[1000001];
bool death[1000001];
int n, k, s[5005], par[5005];
int f(int x) { return par[x] == x ? x : par[x] = f(par[x]); }
int involve[5005], p, lis[5005];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = (1); i <= (n); i++) scanf("%d", &s[i]);
  sort(s + 1, s + n + 1);
  for (int i = (1); i <= (n); i++)
    for (int j = (i + 1); j <= (n); j++) {
      int diff = s[j] - s[i];
      int sz = v[diff].size();
      if (!death[diff]) {
        for (int a = (0); a <= (sz - 1); a++)
          for (int b = (a + 1); b <= (sz - 1); b++) {
            if (v[diff][a].second == i && v[diff][b].second == j) goto die;
          }
        v[diff].push_back(make_pair(i, j));
        if (sz == k) death[diff] = 1;
      die:;
      }
    }
  for (int i = (1); i <= (n); i++) par[i] = i;
  for (int i = (1); i <= (1000001); i++) {
    int cnt = 0;
    p = 0;
    for (int j = i; j <= 1000000; j += i) {
      if (death[j]) goto gg;
      for (auto edge : v[j]) {
        int pa = f(edge.first), pb = f(edge.second);
        if (pa == pb) continue;
        par[pa] = pb;
        if (!involve[pa]) {
          involve[pa] = true;
          lis[++p] = pa;
        }
        cnt++;
        if (cnt > k) goto gg;
      }
    }
    printf("%d\n", i);
    return 0;
  gg:;
    for (int j = (1); j <= (p); j++) {
      involve[lis[j]] = false;
      par[lis[j]] = lis[j];
    }
  }
}
