#include <bits/stdc++.h>
using namespace std;
long long ar[100005];
long long diff[100005];
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n);
  for (long long j = 1; j < n; j++) diff[j - 1] = ar[j] - ar[j - 1];
  long long result = ar[n - 1] - ar[0];
  long long p1 = 0, p2 = n - 2;
  long long idx = 1;
  while (p1 < p2) {
    if (k < ((diff[p1] + diff[p2]) * idx)) {
      result -= (k / idx);
      k -= k;
    } else {
      result -= (diff[p1] + diff[p2]);
      k -= (diff[p1] + diff[p2]) * idx;
    }
    p1++;
    p2--;
    idx++;
  }
  if (p1 == p2) {
    if (k < diff[p1] * idx) {
      result -= (k / idx);
    } else {
      result -= diff[p1];
    }
  }
  cout << result << endl;
  return 0;
}
