#include <bits/stdc++.h>
using namespace std;
int n, kk;
int num[1000100][14];
int cnt[1000100];
int a[5100];
int main() {
  cin >> n >> kk;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int x = a[j] - a[i];
      if (cnt[x] > 12) {
        continue;
      }
      num[x][cnt[x]] = a[i];
      cnt[x]++;
    }
  }
  int m = a[n - 1];
  for (int k = max(1, n - kk); k <= m; ++k) {
    vector<int> s;
    for (int i = k; i <= m; i += k) {
      for (int x = 0; x < cnt[i]; ++x) {
        s.push_back(num[i][x]);
      }
      if (s.size() > kk * (kk + 1) / 2) {
        break;
      }
    }
    if (s.size() <= kk * (kk + 1) / 2) {
      sort(s.begin(), s.end());
      s.erase(unique(s.begin(), s.end()), s.end());
      int ans = s.size();
      if (ans <= kk) {
        cout << k << endl;
        return 0;
      }
    }
  }
  return 0;
}
