#include <bits/stdc++.h>
using namespace std;
int n, i, j, k, h;
int a[10005], num[1000005], vis[1000005];
int main() {
  while (cin >> n >> k) {
    memset(num, 0, sizeof(num));
    memset(vis, 0, sizeof(vis));
    int xxx = -1;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      xxx = max(xxx, a[i]);
    }
    for (i = 0; i < n; i++)
      for (j = 0; j < i; j++) num[abs(a[i] - a[j])]++;
    int flag = 0;
    xxx++;
    for (i = 1; i <= xxx && !flag; i++) {
      int cnt = 0, sum = 0;
      for (j = i; j <= xxx; j += i) {
        sum += num[j];
        if (sum > (k * (k + 1) / 2)) break;
      }
      if (sum > (k * (k + 1) / 2)) continue;
      flag = i;
      for (h = 0; h < n; h++) {
        int c = a[h] % i;
        if (!vis[c])
          vis[c] = 1;
        else if (++cnt > k) {
          flag = 0;
          break;
        }
      }
      for (int l = 0; l < n; l++) vis[a[l] % i] = 0;
    }
    cout << flag << endl;
  }
  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;
int n, i, j, k, h;
int a[10005], num[1000005], vis[1000005];
int main() {
  while (cin >> n >> k) {
    memset(num, 0, sizeof(num));
    memset(vis, 0, sizeof(vis));
    int xxx = -1;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      xxx = max(xxx, a[i]);
    }
    for (i = 0; i < n; i++)
      for (j = 0; j < i; j++) num[abs(a[i] - a[j])]++;
    int flag = 0;
    xxx++;
    for (i = 1; i <= xxx && !flag; i++) {
      int cnt = 0, sum = 0;
      for (j = i; j <= xxx; j += i) {
        sum += num[j];
        if (sum > (k * (k + 1) / 2)) break;
      }
      if (sum > (k * (k + 1) / 2)) continue;
      flag = i;
      for (h = 0; h < n; h++) {
        int c = a[h] % i;
        if (!vis[c])
          vis[c] = 1;
        else if (++cnt > k) {
          flag = 0;
          break;
        }
      }
      for (int l = 0; l < n; l++) vis[a[l] % i] = 0;
    }
    cout << flag << endl;
  }
  return 0;
}

```