#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 200;
const int max_n = 5e3 + 20;
int n, k;
int a[max_n];
vector<pair<int, int>> cnt[MAX];
int fg[MAX];
int mark[MAX], g;
int gg[MAX];
pair<int, int> vec[200];
bool ok(int ans) {
  int t = 0;
  for (int i = ans; i < MAX; i += ans) {
    if (fg[i] > k * (k + 1) / 2) return false;
    for (int j = 0; j < cnt[i].size(); j++) {
      vec[t++] = cnt[i][j];
      if (t > k * (k + 1) / 2) return false;
    }
  }
  g++;
  int c = 0;
  for (int i = 0; i < t; i++) {
    int x = vec[i].first, y = vec[i].second;
    if (mark[x] != g && gg[a[x] % ans]++) c++;
    mark[x] = g;
    if (mark[y] != g && gg[a[y] % ans]++) c++;
    mark[y] = g;
    if (c > k) break;
  }
  for (int i = 0; i < t; i++) {
    pair<int, int> temp = vec[i];
    gg[a[temp.first] % ans] = gg[a[temp.second] % ans] = 0;
  }
  return c <= k;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int x = a[j] - a[i];
      fg[x]++;
    }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int x = a[j] - a[i];
      if (fg[x] <= k * (k + 1) / 2) cnt[x].push_back({i, j});
    }
  for (int i = 1; i < MAX; i++)
    if (ok(i)) {
      printf("%d\n", i);
      return 0;
    }
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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 MAX = 1e6 + 200;
const int max_n = 5e3 + 20;
int n, k;
int a[max_n];
vector<pair<int, int>> cnt[MAX];
int fg[MAX];
int mark[MAX], g;
int gg[MAX];
pair<int, int> vec[200];
bool ok(int ans) {
  int t = 0;
  for (int i = ans; i < MAX; i += ans) {
    if (fg[i] > k * (k + 1) / 2) return false;
    for (int j = 0; j < cnt[i].size(); j++) {
      vec[t++] = cnt[i][j];
      if (t > k * (k + 1) / 2) return false;
    }
  }
  g++;
  int c = 0;
  for (int i = 0; i < t; i++) {
    int x = vec[i].first, y = vec[i].second;
    if (mark[x] != g && gg[a[x] % ans]++) c++;
    mark[x] = g;
    if (mark[y] != g && gg[a[y] % ans]++) c++;
    mark[y] = g;
    if (c > k) break;
  }
  for (int i = 0; i < t; i++) {
    pair<int, int> temp = vec[i];
    gg[a[temp.first] % ans] = gg[a[temp.second] % ans] = 0;
  }
  return c <= k;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int x = a[j] - a[i];
      fg[x]++;
    }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int x = a[j] - a[i];
      if (fg[x] <= k * (k + 1) / 2) cnt[x].push_back({i, j});
    }
  for (int i = 1; i < MAX; i++)
    if (ok(i)) {
      printf("%d\n", i);
      return 0;
    }
  return 0;
}

```