#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 4;
long long n, k;
long long a[N], b[N];
int32_t main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n - 1; i++) b[i] = a[i + 1] - a[i];
  long long ans = a[n] - a[1];
  long long l = 1, r = n - 1, p = 1;
  while (l < r) {
    long long take = min(k, (b[l] + b[r]) * p);
    ans -= take / p;
    k -= take;
    p++;
    l++;
    r--;
  }
  if (l == r) {
    long long take = min(k, b[l] * p);
    ans -= take / p;
    k -= take;
  }
  cout << ans << "\n";
}
