#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
const long long int M = 5e5 + 5;
const long long int mod = 1e9 + 7;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};
const double pi = 3.14159265358979323846;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int modexp(long long int x, long long int n, long long int mod) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result % mod * x % mod) % mod;
    x = (x % mod * x % mod) % mod;
  }
  return result;
}
long long int MOD = 998244353;
long long int po(long long int x, long long int n) {
  if (n < 0) return 0;
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return po((x * x) % MOD, n / 2);
  else
    return (x * po((x * x) % MOD, (n - 1) / 2)) % MOD;
}
long long int modInverse(long long int n, long long int p) {
  return modexp(n, p - 2, p);
}
bool vis[N];
vector<long long int> adj[N];
void dfs(long long int x) {
  vis[x] = true;
  for (int i = 0; i < adj[x].size(); i++) {
    if (!vis[adj[x][i]]) {
      dfs(adj[x][i]);
    }
  }
}
long long int dis[N], ct[N];
void bfs(long long int x) {
  queue<long long int> q;
  q.push(x);
  dis[x] = 1;
  ct[x] = 1;
  while (!q.empty()) {
    long long int t = q.front();
    q.pop();
    for (auto i : adj[t]) {
      if (!dis[i]) {
        dis[i] = dis[t] + 1;
        q.push(i);
        ct[i] = 1;
      } else if (dis[i] == dis[t] + 1)
        ct[i]++;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n + 1];
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  long long int ans = 0;
  for (int i = 1; i <= n / 2; ++i) {
    long long int j = n - i + 1;
    long long int y = (a[i + 1] - a[i] + a[j] - a[j - 1]) * i;
    if (y <= k)
      k -= y;
    else {
      cout << a[j] - a[i] - k / i << '\n';
      return 0;
    }
  }
  cout << ans << '\n';
  return 0;
}
