#include <bits/stdc++.h>
using namespace std;
int n, a[100005], cnt[100005], tot;
long long bac[100005], cntsum[100005];
long long k;
vector<int> vec;
inline long long read() {
  long long ans = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1ll;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    ans = (ans << 1) + (ans << 3) + (c ^ 48), c = getchar();
  return ans * f;
}
inline bool check(int x) {
  long long cur = 1e18, sum = 0;
  int cntl = 0;
  int l = vec[0] - x, r = vec[0];
  for (int i = 0; i < tot - 1; ++i) {
    int t;
    sum += (long long)cntl * (vec[i] - x - l);
    cur = min(cur, sum + bac[i]);
    l = vec[i] - x;
    t = lower_bound(vec.begin(), vec.end(), l) - vec.begin();
    if (vec[t] == l) cntl += cnt[t];
    r = vec[i];
    while (1) {
      t = upper_bound(vec.begin(), vec.end(), l) - vec.begin();
      if (vec[t] - l < vec[i + 1] - r) {
        r += vec[t] - l;
        sum += (long long)(vec[t] - l) * cntl;
        l = vec[t];
        cntl += cnt[t];
        cur = min(cur, sum + bac[i + 1] +
                           (long long)cntsum[i + 1] * (vec[i + 1] - r));
      } else
        break;
    }
  }
  return cur <= k;
}
int main() {
  n = read(), k = read();
  vec.push_back(2e9);
  for (int i = 1; i <= n; ++i) a[i] = read(), vec.push_back(a[i]);
  sort(vec.begin(), vec.end());
  tot = unique(vec.begin(), vec.end()) - vec.begin();
  while (vec.size() > tot) vec.pop_back();
  for (int i = 1; i <= n; ++i)
    cnt[lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin()]++;
  for (int i = tot - 1; i >= 0; i--)
    bac[i] = bac[i + 1] + (long long)(vec[i + 1] - vec[i]) * cntsum[i + 1],
    cntsum[i] = cntsum[i + 1] + cnt[i];
  int l = 0, r = 1e9;
  while (l < r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d", l);
}
