#include <bits/stdc++.h>
using namespace std;
int n, k;
int data[5005];
int flag[1000005];
int f[1000005];
int main() {
  int i, j;
  while (cin >> n >> k) {
    for (i = 1; i <= n; i++) cin >> data[i];
    sort(data + 1, data + 1 + n);
    memset(flag, 0, sizeof(flag));
    for (i = 1; i <= n; i++) {
      for (j = i + 1; j <= n; j++) {
        int t = data[j] - data[i];
        flag[t]++;
      }
    }
    for (i = 1; i <= 1000000; i++)
      for (j = 2 * i; j <= 1000000; j += i) flag[i] += flag[j];
    int m = data[n], ans;
    memset(f, 0, sizeof(f));
    for (ans = 1; ans <= m; ans++) {
      if (flag[ans] > k * (k + 1) / 2) continue;
      for (i = 1; i <= n; i++) f[data[i] % ans]++;
      int cnt = 0;
      for (i = 1; i <= n; i++) {
        if (f[data[i] % ans] > 0) {
          cnt++;
          f[data[i] % ans] = 0;
        }
      }
      cnt = n - cnt;
      if (cnt <= k) break;
    }
    cout << ans << endl;
  }
  return 0;
}
