#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 10;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[MAX_N];
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n / 2; ++i) {
    long long s;
    s = (a[i + 1] - a[i] + a[n - i + 1] - a[n - i]) * i;
    if (k >= s) {
      k -= s;
    } else {
      cout << a[n - i + 1] - a[i] - k / i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}
