#include <bits/stdc++.h>
using namespace std;
int c[1200000], save[5500];
bool flag[1200000];
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &save[i]);
    sort(save + 1, save + n + 1);
    memset(c, 0, sizeof(c));
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++) {
        save[j] > save[i] ? c[save[j] - save[i]]++ : c[save[i] - save[j]]++;
      }
    int K = k * (k + 1) / 2;
    for (int i = 1; i <= save[n] + 1; i++) {
      int temp = 0;
      for (int j = i; j <= save[n] + 1; j += i) {
        temp += c[j];
        if (temp > K) break;
      }
      if (temp <= K) {
        int cnt = 0;
        memset(flag, 0, sizeof(flag));
        for (int j = 1; j <= n; j++) {
          int tt = save[j] % i;
          if (flag[tt]) {
            cnt++;
            if (cnt > k) break;
          }
          flag[tt] = 1;
        }
        if (cnt <= k) {
          printf("%d\n", i);
          break;
        }
      }
    }
  }
  return 0;
}
