#include <bits/stdc++.h>
const int mod = 1e9 + 9;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 50;
const int root = 1e6 + 7;
using namespace std;
long long n, m, k, len;
int a[maxn];
bool vis[maxn];
int b[10];
int df[maxn];
int ma;
bool judge(int x) {
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (vis[a[i]]) {
      for (int j = a[i] + x; j <= ma; j += x) {
        if (vis[j]) {
          vis[j] = false;
          b[cnt++] = j;
          if (cnt > k) {
            for (int kk = 0; kk < cnt; kk++) vis[b[kk]] = true;
            return false;
          }
        }
      }
    }
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    vis[a[i]] = true;
    ma = max(ma, a[i]);
  }
  sort(a, a + n);
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      ++df[a[j] - a[i]];
    }
  }
  int lm = (k + 1) * k / 2;
  for (int i = max(n - k, 1ll);; i++) {
    int s = 0;
    for (int j = i; j <= (int)1e6; j += i) s += df[j];
    if (s <= lm && judge(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}
