#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000100;
int n, k;
int a[MAXN];
vector<int> ima[MAXN];
int cookie, bio[MAXN], md[MAXN];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < MAXN; ++i) ima[i].reserve(10);
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      int diff = abs(a[i] - a[j]);
      if ((int)ima[diff].size() < k * 2 + 2) {
        ima[diff].push_back(a[i]);
        ima[diff].push_back(a[j]);
      }
    }
  vector<int> v;
  for (int i = 1; i < MAXN; ++i) {
    ++cookie;
    int cnt = 0;
    for (int j = i; j < MAXN; j += i) {
      if ((int)ima[j].size() >= 2 * k + 2) {
        cnt = k + 1;
        break;
      }
      for (int x : ima[j]) {
        if (bio[x] == cookie) continue;
        bio[x] = cookie;
        if (md[x % i] == cookie)
          ++cnt;
        else
          md[x % i] = cookie;
      }
      if (cnt > k) break;
    }
    if (cnt <= k) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
