Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right.

Once Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed that this box originally had at least one ball), and began putting balls (one at a time) to the boxes with numbers i + 1, i + 2, i + 3 and so on. If Vasya puts a ball into the box number n, then the next ball goes to box 1, the next one goes to box 2 and so on. He did it until he had no balls left in his hands. It is possible that Vasya puts multiple balls to the same box, and it is also possible that one or more balls will go to the box number i. If i = n, Vasya puts the first ball into the box number 1, then the next ball goes to box 2 and so on. 

For example, let's suppose that initially Vasya had four boxes, and the first box had 3 balls, the second one had 2, the third one had 5 and the fourth one had 4 balls. Then, if i = 3, then Vasya will take all five balls out of the third box and put them in the boxes with numbers: 4, 1, 2, 3, 4. After all Vasya's actions the balls will lie in the boxes as follows: in the first box there are 4 balls, 3 in the second one, 1 in the third one and 6 in the fourth one.

At this point Vasya has completely forgotten the original arrangement of the balls in the boxes, but he knows how they are arranged now, and the number x — the number of the box, where he put the last of the taken out balls.

He asks you to help to find the initial arrangement of the balls in the boxes.


-----Input-----

The first line of the input contains two integers n and x (2 ≤ n ≤ 10^5, 1 ≤ x ≤ n), that represent the number of the boxes and the index of the box that got the last ball from Vasya, correspondingly. The second line contains n space-separated integers a_1, a_2, ..., a_{n}, where integer a_{i} (0 ≤ a_{i} ≤ 10^9, a_{x} ≠ 0) represents the number of balls in the box with index i after Vasya completes all the actions. 

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Output-----

Print n integers, where the i-th one represents the number of balls in the box number i before Vasya starts acting. Separate the numbers in the output by spaces. If there are multiple correct solutions, you are allowed to print any of them.


-----Examples-----
Input
4 4
4 3 1 6

Output
3 2 5 4 
Input
5 2
3 2 0 2 7

Output
2 1 4 1 6 
Input
3 3
2 3 1

Output
1 2 3

Difficulty: interview

Starter code:

Solutions:
n, x = map(int, input().split())
t = list(map(int, input().split()))
m = min(t[: x])
if m == 0:
    i = x - 1
    while t[i]: i -= 1
    t[i + 1: x] = [j - 1 for j in t[i + 1: x]]
    t[i] = x - i - 1
else:
    t[: x] = [i - 1 for i in t[: x]]
    m = min(t)
    if m: t = [i - m for i in t]
    i = n - 1    
    while t[i]: i -= 1
    t[i + 1: ] = [j - 1 for j in t[i + 1: ]]
    t[i] = x + m * n + n - i - 1
print(' '.join(map(str, t)))

n,x=map(int,input().split())

A={}

L=list(map(int,input().split()))

minn=min(L)


ind=x-1
    
while(L[ind]!=minn):
    ind-=1
    if(ind==-1):
        ind=n-1
        


iterations=L[ind]

Diff=[0]*n
r=1
inc=True
if(x-1==ind):
    inc=False
i=ind+1
start=True

rem=0
while(i!=ind+1 or start):
    start=False
    if(i==n):
        i=0
    if(i==x-1 and inc):
        rem+=1
        inc=False
        L[i]-=iterations+r
        i+=1
        continue
    if(inc):
        rem+=1
        L[i]-=iterations+r
    else:
        L[i]-=iterations
    i+=1
if(ind!=0):
    if(L[0]<0):
        while(1):
            x=1
    print(L[0],end="")
else:
    print(iterations*n+rem,end="")
for i in range(1,n):
    if(i==ind):
        print(" "+str(iterations*n+rem),end="")
        continue
    if(L[i]<0):
        while(1):
            x=1
    print(" "+str(L[i]),end="")
print()


n, x = map(int, input().split())
a = list(map(int, input().split()))
t = min(a)
if t != 0:
    for i in range(n):
        a[i] -= t - 1
i = x - 1
c = 0
while a[i] != 0:
    a[i] -= 1
    c += 1
    i -= 1
    if i == -1:
        i = n - 1
a[i] += c + max(t - 1, 0) * n
for i in a:
    print(i, end = ' ')
    

n,l=input().split()
n=int(n)
l=int(l)
l=l-1
a=list(map(int,input().split()))
min=float('inf')
for i in range(n-1,-1,-1):
    if(a[i]<min):
        min=a[i]
        pos=i
if(a[l]==min):
    pos=l
if(l>=pos):
    for i in range(0,n):
        a[i]-=min
    for i in range(pos+1,l+1):
        a[i]-=1
    a[pos]=n*min+l-pos
else:
    found=0
    for i in range(l,-1,-1):
        if(a[i]==min):
            pos=i
            found=1
            break
    if(found==1):
        for i in range(0,n):
            a[i]-=min
        for i in range(pos+1,l+1):
            a[i]-=1
        a[pos]=n*min+l-pos
    else:
        for i in range(0,n):
            a[i]-=min
        for i in range(pos+1,n):
            a[i]-=1
        for i in range(0,l+1):
            a[i]-=1
        a[pos]=n*min+n-pos+l
        
    

for i in range(0,n):
    print(a[i],end=' ')
        
    
    
    
    
    
    
        
        

            
    

    
    

from math import inf

n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
x -= 1

mx = inf
mi = None
for i in range(x, x - n, -1):
    if a[i] < mx:
        mx = a[i]
        mi = i

mi %= n

for i in range(n):
    a[i] -= mx

a[mi] = mx * n + (x - mi) % n

for i in range(mi + 1 - (n if x < mi else 0), x + 1):
    a[i] -= 1

print(' '.join(map(str, a)))



n=[int(num) for num in input().split()]
x=[int(num) for num in input().split()]
i=n[1]-1
j=(i-1)%n[0]
while j!=n[1]-1:
    if x[j]<x[i]:
        i=j
    j=(j-1)%n[0]    
p=x[i]
j=(n[1]-i-1)%n[0]
if p!=x[n[1]-1]:
    x[i]=p*n[0]+j
    i=i+1
else:
    x[n[1]-1]=p*n[0]
    j=0
    i=n[1]
t=i-1
while True:
    if j!=0:
        j=j-1
        x[i%n[0]]=x[i%n[0]]-1-p
    else:
        x[i%n[0]]=x[i%n[0]]-p
    if (i+1)%n[0]==t:
        break
    else:
        i=(i+1)
for i in x:
    print(i,end=' ')


import math
n,x=list(map(int,input().split()))
a=list(map(int,input().split()))
x-=1
c=(x+1)%n
min1=math.inf
min2=-1
min3=-1
for i in range(n):
    if(min1>=a[c]):
        min1=a[c]
        min2=c
        min3=n-i-1
    c=(c+1)%n


flag=False
c=min2

#print(min1,min2,min3)
for i in range(n):
    a[i]-=min1


for i in range(n):
    a[c]-=1
    
    if(x==c):
        break
    c=(c+1)%n
a[min2]=min3+min1*n
print(*a)


n,x=map(int,input().strip().split())
a=list(map(int,input().strip().split()))
m=min(a)
x-=1
pos=-1
for i in range(n):
    if a[i]==m:
        pos=i
    if i==x and pos!=-1:
        break
for i in range(n):
    a[i]-=m
    a[pos]+=m
    
if x!=pos:
    i=(pos+1)%n
    while i!=x:
        a[i]-=1
        a[pos]+=1
        i=(i+1)%n
    a[pos]+=1
    a[i]-=1
for i in a:
    print(i,end=' ')


from math import inf

n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
x -= 1

mx = inf
mi = None
for i in range(x, x - n, -1):
    if a[i] < mx:
        mx = a[i]
        mi = i

mi %= n

for i in range(n):
    a[i] -= mx

a[mi] = mx * n + (x - mi) % n

for i in range(mi + 1 - (n if x < mi else 0), x + 1):
    a[i] -= 1

print(' '.join(map(str, a)))

	 	 	    	 		  			     			 			



# Made By Mostafa_Khaled


def main():
    n, x = map(int,input().split())
    a = [int(i) for i in input().split()]
    j = x - 1
    z = min(a)
    while a[j] != z:
        if j == 0:
            j = n - 1
        else:
            j -= 1
    m = a[j]
    k = 0
    if x - 1 > j:
        for i in range(n):
            if j < i <= x - 1:
                a[i] -= (m + 1)
                k += (m + 1)
            else:
                a[i] -= m
                k += m
        a[j] += k
    elif x - 1 < j:
        for i in range(n):
            if x - 1 < i <= j:
                a[i] -= m
                k += m
            else:
                a[i] -=(m + 1)
                k += (m + 1)
        a[j] += k
    else:
        for i in range(n):
            a[i] -= m
            k += m
        a[j] += k
    print(*a)
main()

n, x = list(map(int,input().split()))
a = [int(i) for i in input().split()]
j = x - 1
z = min(a)
while a[j] != z:
    if j == 0:
        j = n - 1
    else:
        j -= 1
m = a[j]
k = 0
if x - 1 > j:
    for i in range(n):
        if j < i <= x - 1:
            a[i] -= (m + 1)
            k += (m + 1)
        else:
            a[i] -= m
            k += m
    a[j] += k
elif x - 1 < j:
    for i in range(n):
        if x - 1 < i <= j:
            a[i] -= m
            k += m
        else:
            a[i] -=(m + 1)
            k += (m + 1)
    a[j] += k
else:
    for i in range(n):
        a[i] -= m
        k += m
    a[j] += k
print(*a)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

n, x = mints()
x -= 1
a = list(mints())
m = min(a)
d = max(0, m-2)
if d != 0:
	for i in range(n):
		a[i] -= d
t = n*d
while True:
	a[x] -= 1
	t += 1
	x = (x+n-1) % n
	if a[x] == 0:
		break
a[x] = t
print(*a)


'''input
3 3
2 3 1
'''
from sys import stdin, setrecursionlimit
import math
from collections import defaultdict, deque

setrecursionlimit(15000)


def transform(arr, ans):
	for i in range(len(arr)):
		arr[i] -= ans 


def find_index(x, arr, ):
	i = x - 1 

	while True:
		if arr[i] == 0:
			break
		arr[i] -= 1
		i -= 1
		if i == -1:
			i = n - 1
	return i


def add_remain(x, arr, index):
	i = x - 1
	count = 0
	while True:
		if i == index:
			break
		count += 1
		i -= 1
		if i == -1:
			i = len(arr) - 1
	return count


# main starts
n, x = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
carr = arr[:]
mn = min(arr)
transform(carr, mn)
ans  = mn * n
index = find_index(x, carr)
ans += add_remain(x, arr, index)

for i in range(n):
	arr[i] -= mn
arr[index] = ans
i = x - 1
while True:
	if i == index:
		break
	arr[i] -= 1
	i -= 1
	if i < 0:
		i = n - 1
print(*arr)



l=input().split()
n=int(l[0])
x=int(l[1])
l=input().split()
li=[int(i) for i in l]
mina=li[0]
ind=0
for i in range(1,n):
    if(li[i]<=mina):
        ind=i
        mina=li[i]
indexofx=x-1
for i in range(n):
    if(li[(indexofx+n-i)%n]==mina):
        ind=(indexofx+n-i)%n
        break
quot=li[ind]
indexofx=x-1
if(indexofx>=ind):
    rem=indexofx-ind
else:
    rem=n-1-ind+indexofx+1
l=[0 for i in range(n)]
for i in range(n):
    if(i!=ind):
        l[i]=li[i]-quot
l[ind]=(quot*n)+rem
for i in range(1,rem+1):
    l[(ind+i)%n]-=1
for i in l:
    print(i,end=" ")
print()


import sys
lines = sys.stdin.readlines()

(n,x) = map(int, lines[0].strip().split(" "))
nums = list(map(int, lines[1].strip().split(" ")))

minSoFar = min(nums)
index = -1
for i in range(x+n-1, x-1, -1):
    if nums[i%n] == minSoFar:
        index = i%n; break
tmp = nums[index]
num = tmp * n + (x-1+n-index) % n
for i in range(n):
    nums[i] -= tmp
for i in range(1, (x-1 + n - index) % n+1):
    nums[(i+index)%n] -= 1
nums[index] = num
print(" ".join(map(str, nums)))

n,x=map(int,input().split())
a=list(map(int,input().split()))
x-=1
y=max(0,min(a))
for i in range(n):
    a[i]-=y
flag=False
cnt=0
for i in range(x,-1,-1):
    if a[i]==0:
        a[i]=cnt+(y*n)
        flag=True
        break
    a[i]-=1
    cnt+=1
for i in range(n-1,x,-1):
    if flag:
        break
    if a[i]==0:
        a[i]=cnt+(y*n)
        break
    a[i]-=1
    cnt+=1
print(*a)    

n,x = map(int,input().split())
a = list(map(int,input().split()))
m = min(a)
f = x-1
for i in range(n):
	if(a[f] == m):
		st = f
		break
	f = (f-1)%n
c = m+1
ct = 0
for i in range(n):
	a[st] -= c
	ct += c
	if(st == x-1): c -= 1
	st = (st+1)%n
a[st] = ct-1
print(*a)

n, dest =  list(map(int, input().split()))
dest -= 1
a = list(map(int, input().split()))

m1 = float('inf'); m2 = float('inf')
pos1 = -1; pos2 = -1

for i in range(dest + 1):
    if a[i] <= m1:
        m1 = a[i]
        pos1 = i


for i in range(dest + 1, n):
    if a[i] <= m2:
        m2 = a[i]
        pos2 = i


if m2 < m1:
    c = 0
    for i in range(n):
        if dest + 1 <= i <= pos2:
            c += m2
            a[i] -= m2
        else:
            c += (m2+1)
            a[i] -= (m2+1)
    a[pos2] = c
else:
    c = 0
    for i in range(n):
        if pos1 + 1 <= i <= dest:
            c += m1 + 1
            a[i] -= m1 + 1
        else:
            c += m1
            a[i] -= m1
    a[pos1] = c
    
print(*a)



def solve(n, x, seq):
    x -= 1
    _min = min(seq)
    s = sum(seq)
    idx = -1
    for i in range(x, -1, -1):
        if seq[i] == _min:
            idx = i
            break
    else:
        for j in range(n - 1, x, -1):
            if seq[j] == _min:
                idx = j
                break

    for i in range(n):
        seq[i] -= _min

    if idx <= x:
        for j in range(idx + 1, x + 1):
            seq[j] -= 1
    else:
        for j in range(x, -1, -1):
            seq[j] -= 1

        for j in range(n - 1, idx, -1):
            seq[j] -= 1

    seq[idx] = s - sum(seq)
    return seq


def main():
    n, x = list(map(int, input().split()))
    seq = [int(c) for c in input().split()]
    ans = solve(n, x, seq)
    print(*ans)


def __starting_point():
    main()

__starting_point()

import sys
input = sys.stdin.readline


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    4 4

    4 3 1 6

    3 2 4 5

    3 2 5 4
    """
    n, x = read_ints()
    a = read_ints()
    last_min_j = x%n
    for j in range(x, x+n):
        if a[j%n] <= a[last_min_j]:
            last_min_j = j%n
    temp = a[last_min_j]
    a[last_min_j] += n*temp
    a = [a0-temp for a0 in a]
    j = last_min_j+1
    while j%n != x%n:
        a[j%n] -= 1
        j += 1
        a[last_min_j] += 1
    print(*a)


def __starting_point():
    solve()

__starting_point()

n,x=map(int,input().strip().split())
l=list(map(int,input().strip().split()))
m=min(l)
x-=1
p=-1
for i in range(n):
    if l[i]==m:
        p=i
    if i==x and p!=-1:
        break
for i in range(n):
    l[i]-=m
    l[p]+=m
    
if x!=p:
    i=(p+1)%n
    while i!=x:
        l[i]-=1
        l[p]+=1
        i=(i+1)%n
    l[p]+=1
    l[i]-=1
for i in l:
    print(i,end=' ')

n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
idx = x % n
for j in range(x, x+n):
    if a[j % n] <= a[idx]:
        idx = j % n
temp = a[idx]
a[idx] += n * temp
a = [i - temp for i in a]
j = idx + 1
while j % n != x % n:
    a[j % n] -= 1
    j += 1
    a[idx] += 1
print(*a)


n,x=list(map(int,input().split()))
a=list(map(int,input().split()))
m=min(a)
a=[v-m for v in a]
d=m*n
x=x-1
#print(a)
while a[x]>0:
    d=d+1
    a[x]=a[x]-1
    x=x-1
    if x<0:
        x=n-1
a[x]=d
print(' '.join(map(str,a)))


n,x=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
a=[v-m for v in a]
d=m*n
x=x-1
#print(a)
while a[x]>0:
    d=d+1
    a[x]=a[x]-1
    x=x-1
    if x<0:
        x=n-1
a[x]=d
print(' '.join(map(str,a)))