#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
const long long INF = 1e9;
const long long MOD = INF + 7;
string s;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (auto& x : a) cin >> x;
  sort((a).begin(), (a).end());
  vector<long long> dif;
  for (long long i = 1; i < n; i++) {
    dif.push_back(a[i] - a[i - 1]);
  }
  long long ans = a.back() - a.front();
  long long len = ((long long)(dif).size());
  long long lo = 0, hi = len - 1;
  long long cur = 1;
  long long mn;
  while (lo <= hi) {
    if (lo == hi)
      mn = min(k, dif[hi] * cur);
    else
      mn = min(k, (dif[lo] + dif[hi]) * cur);
    k -= mn;
    ans -= mn / cur;
    cur++;
    lo++;
    hi--;
  }
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
