#include <bits/stdc++.h>
using namespace std;
int q[200], a[10000], N, K, vis[6000];
int Head[1005000], Index, Nxt[20000000], xx[20000000], yy[20000000];
inline int abs(int x) { return (x > 0) ? x : (-x); }
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= N; ++i)
    for (int j = i + 1; j <= N; ++j) {
      ++Index;
      xx[Index] = i, yy[Index] = j;
      Nxt[Index] = Head[abs(a[i] - a[j])];
      Head[abs(a[i] - a[j])] = Index;
    }
  for (int ans = 1; ans <= 1000000; ++ans) {
    int tmp = 0;
    for (int i = 0; i * ans <= 1000000; ++i) {
      for (int j = Head[ans * i]; j; j = Nxt[j]) {
        if (vis[xx[j]] != ans) q[++tmp] = xx[j], vis[xx[j]] = ans;
        if (vis[yy[j]] != ans) q[++tmp] = yy[j], vis[yy[j]] = ans;
        if (tmp > K * 2) break;
      }
      if (tmp > K * 2) break;
    }
    if (tmp <= K * 2) {
      int del = 0;
      memset(vis, 0, sizeof(vis));
      for (int i = 1; i <= tmp; ++i)
        if (!vis[i]) {
          ++del;
          for (int j = i + 1; j <= tmp; ++j)
            if (abs(a[q[i]] - a[q[j]]) % ans == 0) vis[j] = 1;
        }
      if (tmp - del <= K) {
        printf("%d\n", ans);
        return 0;
      }
    }
  }
}
