#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  vector<long long> aa(n, 0);
  for (int i = 0; i < n; ++i) scanf("%lld", &aa[i]);
  sort(aa.begin(), aa.end());
  long long cc = aa[n - 1] - aa[0];
  for (int i = 0; i < n / 2; ++i) {
    long long d = ((k / (i + 1) < aa[i + 1] - aa[i]) ? (k / (i + 1))
                                                     : (aa[i + 1] - aa[i]));
    k -= d * (i + 1);
    cc -= d;
    if (n % 2 == 0 && i == (n / 2 - 1)) continue;
    d = ((k / (i + 1) < aa[n - i - 1] - aa[n - i - 2])
             ? (k / (i + 1))
             : (aa[n - i - 1] - aa[n - i - 2]));
    k -= d * (i + 1);
    cc -= d;
  }
  cout << cc << endl;
}
