#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, maxm = (1 << 20) + 5;
const long long mod = 1000000007;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long powermod(long long a, long long b, long long c) {
  a = a % c;
  long long ans = 1;
  while (b) {
    if (b % 2) ans = (ans * a) % c;
    b = b / 2;
    a = (a * a) % c;
  }
  return ans;
}
long long a[maxn];
int main() {
  long long n, k, i, j;
  scanf("%lld%lld", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a + 1, a + n + 1);
  long long flag = 0;
  for (i = 1; i <= n / 2; i++) {
    long long need = (a[i + 1] - a[i] + a[n - i + 1] - a[n - i]) * i;
    if (k > need) {
      k -= need;
    } else {
      flag = 1;
      printf("%lld\n", a[n - i + 1] - a[i] - k / i);
      break;
    }
  }
  if (flag == 0) printf("0\n");
}
