#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n, i, j, k;
  cin >> n >> k;
  long long arr[n + 5];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  sort(arr + 1, arr + n + 1);
  for (i = 1; i <= n / 2; i++) {
    long long j = n - i + 1;
    long long cnt = ((arr[i + 1] - arr[i]) + (arr[j] - arr[j - 1])) * i;
    if (cnt <= k)
      k -= cnt;
    else {
      long long ans = (arr[j] - (arr[i] + k / i));
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}
