#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int nums[n];
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
    if (nums[i] > maxi) {
      maxi = nums[i];
    }
  }
  int diffs[maxi + 1];
  int mo[maxi + 1];
  for (int i = 0; i <= maxi; i++) {
    diffs[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      diffs[abs(nums[i] - nums[j])]++;
    }
  }
  for (int i = 0; i <= maxi; i++) {
    mo[i] = 0;
  }
  int cnt;
  int ans;
  int cnt2;
  for (int i = 1; i <= maxi; i++) {
    cnt = 0;
    for (int j = i; j <= maxi; j = j + i) {
      cnt = cnt + diffs[j];
    }
    if (cnt > k * (k + 1) / 2) {
      continue;
    }
    cnt2 = 0;
    for (int j = 0; j < n; j++) {
      if (mo[nums[j] % i] == i) cnt2++;
      mo[nums[j] % i] = i;
    }
    if (cnt2 <= k) {
      cout << i;
      return 0;
    }
  }
}
