#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int cst;
int cnt[N + 1];
bool is[N + 1];
void solve() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  a[0] = -1;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cnt[abs(a[j] - a[i])]++;
      mx = max(mx, abs(a[j] - a[i]));
    }
  }
  int ans = mx + 1;
  for (int i = 1; i <= mx; i++) {
    cst = 0;
    int Cnt = 0;
    int pos = 1;
    for (int j = i; j <= mx; j += i) {
      Cnt += cnt[j];
      if (Cnt > (k * (k + 1)) / 2) {
        pos = 0;
        break;
      }
    }
    if (!pos) continue;
    map<int, int> mp;
    for (int j = 1; j <= n; j++) {
      int z = a[j] % i;
      if (is[z]) {
        cst++;
      } else
        is[z] = 1;
    }
    if (cst <= k) {
      cout << i << endl;
      return;
    }
    for (int j = 1; j <= n; j++) is[a[j] % i] = 0;
  }
  cout << ans << endl;
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

### Prompt

Create a solution in CPP for the following problem:

You have been given n distinct integers a1, a2, ..., an. You can remove at most k of them. Find the minimum modular m (m > 0), so that for every pair of the remaining integers (ai, aj), the following unequality holds: <image>.

Input

The first line contains two integers n and k (1 ≤ n ≤ 5000, 0 ≤ k ≤ 4), which we have mentioned above. 

The second line contains n distinct integers a1, a2, ..., an (0 ≤ ai ≤ 106).

Output

Print a single positive integer — the minimum m.

Examples

Input

7 0
0 2 3 6 7 12 18


Output

13


Input

7 1
0 2 3 6 7 12 18


Output

7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int cst;
int cnt[N + 1];
bool is[N + 1];
void solve() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  a[0] = -1;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cnt[abs(a[j] - a[i])]++;
      mx = max(mx, abs(a[j] - a[i]));
    }
  }
  int ans = mx + 1;
  for (int i = 1; i <= mx; i++) {
    cst = 0;
    int Cnt = 0;
    int pos = 1;
    for (int j = i; j <= mx; j += i) {
      Cnt += cnt[j];
      if (Cnt > (k * (k + 1)) / 2) {
        pos = 0;
        break;
      }
    }
    if (!pos) continue;
    map<int, int> mp;
    for (int j = 1; j <= n; j++) {
      int z = a[j] % i;
      if (is[z]) {
        cst++;
      } else
        is[z] = 1;
    }
    if (cst <= k) {
      cout << i << endl;
      return;
    }
    for (int j = 1; j <= n; j++) is[a[j] % i] = 0;
  }
  cout << ans << endl;
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```