We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.

There are n citizens in Kekoland, each person has c_{i} coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city and he will give it to the poorest person (poorest person right after taking richest's 1 coin). In case the choice is not unique, he will select one among them at random. Sadly, Robin Hood is old and want to retire in k days. He decided to spend these last days with helping poor people. 

After taking his money are taken by Robin Hood richest person may become poorest person as well, and it might even happen that Robin Hood will give his money back. For example if all people have same number of coins, then next day they will have same number of coins too. 

Your task is to find the difference between richest and poorest persons wealth after k days. Note that the choosing at random among richest and poorest doesn't affect the answer.


-----Input-----

The first line of the input contains two integers n and k (1 ≤ n ≤ 500 000, 0 ≤ k ≤ 10^9) — the number of citizens in Kekoland and the number of days left till Robin Hood's retirement.

The second line contains n integers, the i-th of them is c_{i} (1 ≤ c_{i} ≤ 10^9) — initial wealth of the i-th person.


-----Output-----

Print a single line containing the difference between richest and poorest peoples wealth.


-----Examples-----
Input
4 1
1 1 4 2

Output
2

Input
3 1
2 2 2

Output
0



-----Note-----

Lets look at how wealth changes through day in the first sample.  [1, 1, 4, 2]  [2, 1, 3, 2] or [1, 2, 3, 2] 

So the answer is 3 - 1 = 2

In second sample wealth will remain the same for each person.

Difficulty: competition

Starter code:

Solutions:
import sys

n, k = map(int, sys.stdin.readline().split())
nums = list(map(int, sys.stdin.readline().split()))
total = sum(nums)
avg = int(total / n)

def check1(nums, target, K):
    for x in nums:
        if K < 0:
            return False
        if x < target:
            K -= target - x
    return K >= 0

def check2(nums, target, K):
    for x in nums:
        if K < 0:
            return False
        if x > target:
            K -= x - target
    return K >= 0

l1, r1 = min(nums), avg + 1
while l1 + 1 < r1:
    mid = (l1 + r1) >> 1
    if check1(nums, mid, k):
        l1 = mid
    else:
        r1 = mid

if check2(nums, avg + (0 if total % n == 0 else 1), k):
    r2 = avg + (0 if total % n == 0 else 1)
else:
    l2, r2 = avg + (0 if total % n == 0 else 1), max(nums)
    while l2 + 1 < r2:
        mid = (l2 + r2) >> 1
        if check2(nums, mid, k):
            r2 = mid
        else:
            l2 = mid

print(r2 - l1)

n, k = map(int, input().split())
nums = list(map(int, input().split()))
total = sum(nums)
avg = int(total / n)

def check1(nums, target, K):
    for x in nums:
        if K < 0:
            return False
        if x < target:
            K -= target - x
    return K >= 0

def check2(nums, target, K):
    for x in nums:
        if K < 0:
            return False
        if x > target:
            K -= x - target
    return K >= 0

l1, r1 = min(nums), avg + 1
while l1 + 1 < r1:
    mid = (l1 + r1) >> 1
    if check1(nums, mid, k):
        l1 = mid
    else:
        r1 = mid

if check2(nums, avg + (0 if total % n == 0 else 1), k):
    r2 = avg + (0 if total % n == 0 else 1)
else:
    l2, r2 = avg + (0 if total % n == 0 else 1), max(nums)
    while l2 + 1 < r2:
        mid = (l2 + r2) >> 1
        if check2(nums, mid, k):
            r2 = mid
        else:
            l2 = mid

print(r2 - l1)

def main():
    n, k = list(map(int, input().split()))
    l = sorted(map(int, input().split()))
    lo, hi = l[0], l[-1]
    while lo < hi - 1:
        mid = (lo + hi) // 2
        t = k
        for x in l:
            if x > mid:
                lo = mid
                break
            t -= mid - x
            if t < 0:
                hi = mid
                break
        else:
            lo = mid
    m1 = lo
    lo, hi = l[0], l[-1]
    l.reverse()
    while lo < hi - 1:
        mid = (lo + hi) // 2
        t = k
        for x in l:
            if x < mid:
                hi = mid
                break
            t -= x - mid
            if t < 0:
                lo = mid
                break
        else:
            hi = mid
    print(hi - m1 if hi > m1 else 1 if sum(l) % n else 0)


def __starting_point():
    main()

__starting_point()

import sys

inp = sys.stdin.read().splitlines()
n,k = list(map(int,inp[0].split()))
lst = list(map(int,inp[1].split()))
lst.sort()
total = sum(lst)
lower = int(total/n)
nupper = total%n

if nupper == 0:
	upper = lower;
else:
	upper = lower+1;
nlower = n - nupper;

i = 0;
while i<n and lst[i]<lower:
	i+=1
low1st = i; 

i = n-1;
while i>=0 and lst[i]>upper:
	i-=1
uplast = i;

lowerfill = low1st*lower - sum(lst[:low1st]) 

upperfill = sum(lst[uplast+1:]) - (n-uplast-1)*upper

totalsteps = (lowerfill+upperfill)/2

def filllower():
	kk = k
	cur = lst[0]
	i = 0
	while (kk>0):
		while (lst[i]==cur):
			i+=1
		diff = lst[i] - lst[i-1]
		kk -= i*diff
		if kk == 0:
			cur = lst[i]
			break
		elif kk<0:
			cur = lst[i]-int(-kk/i)-1
			if (-kk%i) ==0:
				cur += 1
			break
		cur = lst[i]
	return cur

def fillupper():
	kk = k
	i = n-1
	cur = lst[i]
	while (kk>0):
		while (lst[i]==cur):
			i-=1
		diff = lst[i+1] - lst[i]
		kk -= (n-i-1)*diff
		if kk == 0:
			cur = lst[i-1]
			break
		elif kk<0:
			cur = lst[i]+int(-kk/(n-i-1))
			if (-kk%(n-i-1)!=0):
				cur += 1;
			break
		cur = lst[i]
	return cur

if totalsteps>=k:
	print(fillupper()-filllower())
else:
	print(upper-lower)


from sys import *
f = lambda: map(int, stdin.readline().split())
n, k = f()
t = sorted(f())
s = [0] * (n + 1)
for i in range(n): s[i + 1] = s[i] + t[i]
t = [0] + t
d = s[n]
l, r = 0, n
while l < r:
    m = l + r + 1 >> 1
    if t[m] * m - s[m] > k: r = m - 1
    else: l = m
x = l
l, r = 0, n
while l < r:
    m = l + r >> 1
    if d - s[m] - t[m] * (n - m) > k: l = m + 1
    else: r = m
y = r
q = (d - s[y - 1] - k + n - y) // (n - y + 1) - (s[x] + k) // x
print(max(q, int(d % n > 0)))

import sys



inp = sys.stdin.read().splitlines()

n,k = list(map(int,inp[0].split()))

lst = list(map(int,inp[1].split()))

lst.sort()

total = sum(lst)

lower = int(total/n)

nupper = total%n



if nupper == 0:

	upper = lower;

else:

	upper = lower+1;

nlower = n - nupper;



i = 0;

while i<n and lst[i]<lower:

	i+=1

low1st = i; 



i = n-1;

while i>=0 and lst[i]>upper:

	i-=1

uplast = i;



lowerfill = low1st*lower - sum(lst[:low1st]) 



upperfill = sum(lst[uplast+1:]) - (n-uplast-1)*upper



totalsteps = (lowerfill+upperfill)/2

'''

print("nlower = %d"%nlower)

print("nupper = %d"%nupper)

print("lower = %d"%lower)

print("upper = %d"%upper)

print("lowerfill = %d"%lowerfill)

print("upperfill = %d"%upperfill)

print("totalsteps = %f"%totalsteps)

'''

def filllower():

	kk = k

	cur = lst[0]

	i = 0

	while (kk>0):

		while (lst[i]==cur):

			i+=1

			#print("i=%d,lst[i]=%d"%(i,lst[i]))

		diff = lst[i] - lst[i-1]

		kk -= i*diff

		#print("lower kk = %d",kk)

		if kk == 0:

			cur = lst[i]

			break

		elif kk<0:

			cur = lst[i]-int(-kk/i)-1

			#print("-kk/i = %d",int(-kk/i))

			if (-kk%i) ==0:

				cur += 1

			break

		cur = lst[i]

	#print("min = ",cur)

	return cur



def fillupper():

	kk = k

	i = n-1

	cur = lst[i]

	while (kk>0):

		while (lst[i]==cur):

			i-=1

			#print("i=%d,lst[i]=%d"%(i,lst[i]))

		diff = lst[i+1] - lst[i]

		kk -= (n-i-1)*diff

		#print("upper kk = ",kk)

		if kk == 0:

			cur = lst[i-1]

			break

		elif kk<0:

			cur = lst[i]+int(-kk/(n-i-1))

			if (-kk%(n-i-1)!=0):

				cur += 1;

			break

		cur = lst[i]

	#print("max = ",cur)

	return cur



if totalsteps>=k:

	print(fillupper()-filllower())

else:

	print(upper-lower)







'''





def sortmax():

	v = lst[-1]

	i = n-2

	while(i>=0):

		if lst[i]<=v:

			lst[-1]=lst[i+1]

			lst[i+1]=v

			return

		i-=1

	lst[-1]=lst[0]

	lst[0]=v



def sortmin():

	v = lst[0]

	i = 1

	while(i<n):

		if lst[i]>=v:

			lst[0]=lst[i-1]

			lst[i-1]=v

			return

		i+=1

	lst[0]=lst[-1]

	lst[-1]=v





lst.sort()

while k:

	lst[-1]-=1

	sortmax()

	#print(lst)

	lst[0]+=1

	sortmin()

	if (lst[-1]-lst[0])<=1:

		break

	#print(lst)

	k-=1





print(lst[-1]-lst[0])





'''



# Made By Mostafa_Khaled


# https://codeforces.com/problemset/problem/671/B

n, k = list(map(int, input().split()))
a    = sorted(list(map(int, input().split())))

def solve(a, k):
    b  = a[::-1]
    S  = sum(a)
    n  = len(a)
    div   = S // n
    re    = S % n
    T     = 0
    
    num = re
    
    for i in range(n-1, -1, -1):
        thres = div 
    
        if num > 0:
            thres += 1
            num -= 1
    
        if a[i] > thres:
            T += a[i] - thres

    if k >= T:
        return 1 if re > 0 else 0
    
    l_arr = [0] * n
    r_arr = [0] * n
    
    for i in range(1, n):
        l_arr[i] = (a[i] - a[i-1]) * i 
        
    for i in range(1, n):
        r_arr[i] = (b[i-1] - b[i]) * i
    
    remain = k
    l, u   = a[0], b[0]
    
    for i in range(1, n):
        if remain >= l_arr[i]:
            remain -= l_arr[i]
            l = a[i]
        else:
            l += remain // i
            break
            
    remain = k        
    
    for i in range(1, n):
        if remain >=  r_arr[i]:
            remain -= r_arr[i]
            u  = b[i]
        else:
            u -= remain // i
            break
            
    return u - l#, a, l_arr, r_arr

print(solve(a, k))

#4 1
#1 1 4 2


from sys import stdin

n,k = [int(x) for x in stdin.readline().split()]
oK = k

c = sorted([int(x) for x in stdin.readline().split()])

l = 0
r = n-1

low = c[0]
high = c[-1]

lowBuffer = 0
highBuffer = 0

while low < high:
    if low == c[l]:
        l += 1
    if high == c[r]:
        r -= 1

    if l*(c[l]-low)-lowBuffer > (n-r-1)*(high-c[r])-highBuffer <= k:
        #print(low,high,l,r,'highDown', (n-r-1)*(high-c[r])-highBuffer)
        
        k -= (n-r-1)*(high-c[r])-highBuffer
        lowBuffer += (n-r-1)*(high-c[r])-highBuffer
        highBuffer = 0
        high = c[r]

    elif (n-r-1)*(high-c[r])-highBuffer >= l*(c[l]-low)-lowBuffer <= k:
        #print(low,high,l,r,'lowUp',l*(c[l]-low)-lowBuffer)
        k -= l*(c[l]-low)-lowBuffer
        highBuffer += l*(c[l]-low)-lowBuffer
        lowBuffer = 0
        low = c[l]
    else:
        low += (lowBuffer+k)//l
        high -= (highBuffer+k)//(n-r-1)
        k = 0
        break

if sum(c)%n == 0:
    print(max(0,high-low))
else:
    print(max(1,high-low))