#include <bits/stdc++.h>
using namespace std;
const int M = 1000000 + 5;
int a[M];
int d[M];
int vis[M];
int main() {
  time_t t_start, t_end;
  t_start = clock();
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int v = abs(a[i] - a[j]);
      d[v]++;
    }
  }
  for (int p = 1; p < M; p++) {
    long long int s = 0;
    for (int i = p; i < M; i += p) {
      s = s + d[i];
    }
    if (s > k * (k + 1) / 2) {
      ;
    } else {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (vis[a[i] % p] == p) {
          cnt++;
        } else {
          vis[a[i] % p] = p;
        }
        if (cnt > k) {
          break;
        }
      }
      if (cnt <= k) {
        cout << p << endl;
        break;
      }
    }
  }
  t_end = clock();
  return 0;
}
