/// Minimizing Difference
/// Author: Qwerty
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 100;
int n;
long long k;
long long a[MAXN];
long long b[MAXN];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1);
for (int i = 1; i < n; i++){
b[i] = a[i + 1] - a[i];
}
int l = 1;
int r = n - 1;
long long c = 1;
int ans = a[n] - a[1];
while (l < r){
long long s = min(k, (b[l] + b[r]) * c);
ans -= s / c;
k -= s;
c++;
l++;
r--;
}
if (l == r){
long long s = min(k, b[l] * c);
ans -= s / c;
k -= s;
}
cout << ans << '\n';
}
Ly8vIE1pbmltaXppbmcgRGlmZmVyZW5jZQovLy8gQXV0aG9yOiBRd2VydHkKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE1BWE4gPSAxZTUgKyAxMDA7CmludCBuOwpsb25nIGxvbmcgazsKbG9uZyBsb25nIGFbTUFYTl07CmxvbmcgbG9uZyBiW01BWE5dOwppbnQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBjaW4gPj4gbiA+PiBrOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSBjaW4gPj4gYVtpXTsKICAgIHNvcnQoYSArIDEsIGEgKyBuICsgMSk7CiAgICBmb3IgKGludCBpID0gMTsgaSA8IG47IGkrKyl7CiAgICAgICAgIGJbaV0gPSBhW2kgKyAxXSAtIGFbaV07CiAgICB9CiAgICBpbnQgbCA9IDE7CiAgICBpbnQgciA9IG4gLSAxOwogICAgbG9uZyBsb25nIGMgPSAxOwogICAgaW50IGFucyA9IGFbbl0gLSBhWzFdOwogICAgd2hpbGUgKGwgPCByKXsKICAgICAgICBsb25nIGxvbmcgcyA9IG1pbihrLCAoYltsXSArIGJbcl0pICogYyk7CiAgICAgICAgYW5zIC09IHMgLyBjOwogICAgICAgIGsgLT0gczsKICAgICAgICBjKys7CiAgICAgICAgbCsrOwogICAgICAgIHItLTsKICAgIH0KICAgIGlmIChsID09IHIpewogICAgICAgIGxvbmcgbG9uZyBzID0gbWluKGssIGJbbF0gKiBjKTsKICAgICAgICBhbnMgLT0gcyAvIGM7CiAgICAgICAgayAtPSBzOwogICAgfQogICAgY291dCA8PCBhbnMgPDwgJ1xuJzsKfQo=