//fryinduc
#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
const int maxn = 5e5 + 5;
int n, t, a[maxn];
void solve() {
  cin >> n >> t;
  vector<int> vec;
  for(int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] %= t;
  }
  sort(a + 1, a + n + 1);
  int res = a[n] - a[1];
  for(int i = 2; i <= n; ++i) {
    res = min(res, t - a[i] + a[i - 1]);
  }
  cout << (res + 1) / 2;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |