#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[5002];
int cnt[1000002], F[1000002];
int main() {
  srand(time(0));
  cin.sync_with_stdio(false);
  cin >> N >> K;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  for (int i = 1; i <= N; ++i)
    for (int j = i + 1; j <= N; ++j) ++cnt[max(A[i], A[j]) - min(A[i], A[j])];
  int limit = K * (K + 1) / 2;
  for (int i = 1; i <= 1000001; ++i) {
    bool ok = true;
    int total = 0;
    for (int j = i; j <= 1000000 && ok; j += i) {
      total += cnt[j];
      if (total > limit) {
        ok = false;
        break;
      }
    }
    int count = 0;
    if (ok) {
      for (int j = 1; j <= N && ok; ++j) {
        int now = A[j] % i;
        if (F[now] == 0)
          F[now] = 1;
        else {
          ++count;
          if (count > K) break;
        }
      }
      for (int j = 1; j <= N; ++j) F[A[j] % i] = 0;
    }
    if (ok && count <= K) {
      cout << i << '\n';
      break;
    }
  }
}

### Prompt

Generate a Cpp solution to 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, K;
int A[5002];
int cnt[1000002], F[1000002];
int main() {
  srand(time(0));
  cin.sync_with_stdio(false);
  cin >> N >> K;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  for (int i = 1; i <= N; ++i)
    for (int j = i + 1; j <= N; ++j) ++cnt[max(A[i], A[j]) - min(A[i], A[j])];
  int limit = K * (K + 1) / 2;
  for (int i = 1; i <= 1000001; ++i) {
    bool ok = true;
    int total = 0;
    for (int j = i; j <= 1000000 && ok; j += i) {
      total += cnt[j];
      if (total > limit) {
        ok = false;
        break;
      }
    }
    int count = 0;
    if (ok) {
      for (int j = 1; j <= N && ok; ++j) {
        int now = A[j] % i;
        if (F[now] == 0)
          F[now] = 1;
        else {
          ++count;
          if (count > K) break;
        }
      }
      for (int j = 1; j <= N; ++j) F[A[j] % i] = 0;
    }
    if (ok && count <= K) {
      cout << i << '\n';
      break;
    }
  }
}

```