#include <bits/stdc++.h>
using namespace std;
int A[5005], K;
bool rem[1000006], add[1000006], bad[1000006];
vector<int> D[1000006];
vector<int>::iterator it;
int main() {
  int N;
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
    for (int j = 0; j < i; ++j) {
      int d = abs(A[i] - A[j]);
      if (D[d].size() == 2 * K)
        bad[d] = 1;
      else {
        D[d].push_back(A[i]);
        D[d].push_back(A[j]);
      }
    }
  }
  for (int m = 1; m <= 1000001; ++m) {
    bool fail = 0;
    for (int k = m; k <= 1000000; k += m)
      if (bad[k]) {
        fail = 1;
        break;
      }
    if (fail) continue;
    int used = 0;
    vector<int> proc;
    for (int k = m; k <= 1000000; k += m)
      for (it = D[k].begin(); it != D[k].end(); ++it)
        if (!rem[*it]) {
          rem[*it] = 1;
          ++used;
          int v = *it % m;
          if (!add[v]) {
            add[v] = 1;
            --used;
          }
          proc.push_back(*it);
          if (used > K) goto end;
        }
    if (used <= K) {
      printf("%d\n", m);
      return 0;
    }
  end:;
    for (it = proc.begin(); it != proc.end(); ++it) rem[*it] = add[*it % m] = 0;
  }
}
