#include <bits/stdc++.h>
long long int c[1000000];
using namespace std;
int main() {
  long long int sum_full = 0, n, k;
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) {
    cin >> c[i];
    sum_full += c[i];
  }
  sort(c, c + n);
  if (k == 0) {
    cout << c[n - 1] - c[0] << endl;
    return 0;
  }
  long long int back_i = 0, front_i, sum_front = 0, sum_back = 0;
  for (front_i = 0; front_i < n - 1; front_i++) {
    sum_front += c[front_i];
    if (((front_i + 1) * c[front_i + 1] - sum_front) >= k) {
      break;
    }
  }
  for (back_i = n - 1; back_i > 0; back_i--) {
    sum_back += c[back_i];
    if ((-(n - back_i) * c[back_i - 1] + sum_back) >= k) {
      break;
    }
  }
  if (front_i >= back_i) {
    if (sum_full % n != 0) {
      cout << "1" << endl;
      return 0;
    }
    cout << "0" << endl;
    return 0;
  }
  if (-((sum_front + k) / (front_i + 1) -
        (sum_back - k + n - back_i - 1) / (n - back_i)) == 0 &&
      sum_full % n != 0) {
    cout << "1" << endl;
    return 0;
  }
  cout << -((sum_front + k) / (front_i + 1) -
            (sum_back - k + n - back_i - 1) / (n - back_i))
       << endl;
  return 0;
}
