#include <bits/stdc++.h>
using namespace std;
vector<int> df[1000005];
bool taken[1000005];
bool used[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i <= 1000000; ++i) {
    df[i].reserve(10);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (i != j) {
        int c = abs(v[i] - v[j]);
        if ((int)df[c].size() < 2 * (k + 1)) {
          df[c].push_back(v[i]);
          df[c].push_back(v[j]);
        }
      }
    }
  }
  for (int m = 1; m <= 1000001; ++m) {
    vector<int> cused;
    int res = 0;
    for (int d = 0; d <= 1000000; d += m) {
      if ((int)df[d].size() >= 2 * (k + 1)) {
        res = k + 1;
        break;
      }
      for (__typeof(df[d].begin()) it = (df[d].begin()); it != (df[d]).end();
           ++it) {
        if (used[*it]) {
          continue;
        }
        int a = *it % m;
        if (taken[a]) {
          ++res;
        } else {
          taken[a] = true;
        }
        used[*it] = true;
        cused.push_back(*it);
      }
      if (res > k) {
        break;
      }
    }
    if (res <= k) {
      cout << m << endl;
      return 0;
    }
    for (__typeof(cused.begin()) it = (cused.begin()); it != (cused).end();
         ++it) {
      used[*it] = false;
      taken[*it % m] = false;
    }
  }
}
