/** Micro Mezzo Macro Flation -- Overheated Economy ., Last Update: Dec. 24th 2012 **/ //{

/** Header .. **/ //{
#define LOCAL

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (int n____=(i=0,int(n));i<n____;++i)
#define FOR_C_N(i, a, b) for (int b____=(i=0,int(b);i<b____;++i)
#define DWN_C_N(i, b, a) for (int a____=(i=b-1,int(a));i>=a____;--i)
#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)

#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define REP_S(i, str) for (char*i=str;*i;++i)
#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])
#define REP_G(i, u) REP_L(i,hd[u],suc)
#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)
#define PTT pair<T, T>
#define fi first
#define se second

#define Rush for(int ____T=RD(); ____T--;)

#define Display(A, n, m) {                      \
	REP(i, n){		                            \
        REP(j, m) cout << A[i][j] << " ";       \
        cout << endl;				            \
	}						                    \
}

#define Display_1(A, n, m) {				    \
	REP_1(i, n){		                        \
        REP_1(j, m) cout << A[i][j] << " ";     \
		cout << endl;		            		\
	}						                    \
}

#pragma comment(linker, "/STACK:36777216")
//#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Python system("python main.py")
#define Pascal system("fpc main.pas")

typedef long long LL;
//typedef long double DB;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;

template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
inline LL RD(){LL x; return RD(x);}
inline DB& RF(DB &);
inline DB RF(){DB x; return RF(x);}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){char c; return RC(c);}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();}

template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
inline char& RC(char &a, char &b){RC(a), RC(b); return a;}
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}
inline void RS(char *s1, char *s2){RS(s1), RS(s2);}
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}
template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}

template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;}
template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}
template<class T> inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A))) - A.begin());return A;}

//}

/** Constant List .. **/ //{

//const int MOD = 1000000007;
int MOD = 99990001;
const int INF = 0x3f3f3f3f;
const LL INFF = 1LL << 60;
const DB EPS = 1e-9;
const DB OO = 1e15;
const DB PI = acos(-1.0); //M_PI;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//}

/** Add On .. **/ //{
// <<= '0. Nichi Joo ., //{
template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (a<b) a=b;}
template<class T> inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}
template<class T> inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
inline int ceil(int x, int y){return (x - 1) / y + 1;}
inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);}
//}

// <<= '2. Number Theory .,//{
namespace NT{
//inline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}
inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

inline int sum(int a, int b, int c){return sum(sum(a, b), c);}
inline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}
inline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}
inline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}

inline int pow(int a, int b){
    int c(1); while (b){
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

inline int pow(int a, LL b){
    int c(1); while (b){
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

template<class T> inline T pow(T a, LL b){
    T c(1); while (b){
        if (b&1) c *= a;
        a *= a, b >>= 1;
    }
    return c;
}

inline int _I(int b){
    int a = MOD, x1 = 0, x2 = 1, q;
    while (true){
        q = a / b, a %= b;
        if (!a) return (x2 + MOD) % MOD;
        DEC(x1, pdt(q, x2));

        q = b / a, b %= a;
        if (!b) return (x1 + MOD) % MOD;
        DEC(x2, pdt(q, x1));
    }
}

inline void DIV(int &a, int b){MUL(a, _I(b));}
inline int qtt(int a, int b){return pdt(a, _I(b));}

inline int phi(int n){
    int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){
        DEC(res, qtt(res, i));
        do{n /= i;} while(!(n%i));
    }
    if (n != 1)
        DEC(res, qtt(res, n));
    return res;
}

} using namespace NT;//}

/** I/O Accelerator Interface .. **/ //{
template<class T> inline T& RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
    /*char c; for (c = getchar(); c != '-' && c < '0'; c = getchar());
    if (c == '-'){x = 0; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}
    else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}*/
    return x;
}

inline DB& RF(DB &x){
    scanf("%lf", &x);
    /*char t; while ((t=getchar())==' '||t=='\n'); x = t - '0';
    while ((t=getchar())!=' '&&t!='\n'&&t!='.')x*=10,x+=t-'0';
    if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\n')l*=0.1,x += (t-'0')*l;}*/
    return x;
}

inline char* RS(char *s){
    //gets(s);
    scanf("%s", s);
    return s;
}

int Case; template<class T> inline void OT(const T &x){
    //printf("Case %d: %d\n", ++Case, x);
    //printf("%.2lf\n", x);
    printf("%d\n", x);
    //cout << x << endl;
}
//}

//}/* .................................................................................................................................. */

const int N = 1000009;

int P[N], R[N], nn; LL A[N];
int n, m, p;

void Make(int x){
    R[x] = 0, P[x] = x;
}

void Init(){
    REP(i, n) Make(i);
}

int Find(int x){
    return P[x] = P[x] == x ? x : Find(P[x]);
}

void Union(int x, int y){
    x = Find(x), y = Find(y);
    if (x == y) return;
    if (R[x] < R[y]) P[x] = y;
    else {
        if (R[x] == R[y]) ++R[x];
        P[y] = x;
    }
    --nn;
}

//VII A, B;

int main(){

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

/*
    REP_C(i, RD(n)){
        int t = RD();
        if (t) A.PB(MP(RD(), i)); else B.PB(MP(RD(), i));
    }

    Init();

    SRT(A, greater<PII>()), SRT(B, greater<PII>());

    //REP(i, SZ(A)) cout << A[i].fi << " " << A[i].se << endl;

    REP(i, SZ(A)){
        REP(j, SZ(B)) if (B[j].fi){

            if (Find(A[i].se) == Find(B[j].se)) continue;

        if (A[i].fi <= B[j].fi){
            int d = A[i].fi; B[j].fi -= d;
            cout << A[i].se+1 << " " << B[j].se+1 << " " << d << endl;
            Union(A[i].se, B[j].se);
            break;
        }
        else {
            int d = B[j].fi; A[i].fi -= d;
            cout << A[i].se+1 << " " << B[j].se+1 << " " << d << endl;
            Union(A[i].se, B[j].se);
        }
        }
    }

    REP(i, SZ(A)) REP(j, SZ(B)){
        if (Find(A[i].se) != Find(B[j].se)){
             cout << A[i].se+1 << " " << B[j].se+1 << " " << 0 << endl;
             Union(A[i].se, B[j].se);
        }
    }*/

    int t; RD(n, t);

    m = 1;
    REP_1(i, n){
        if (RD(A[i]) < A[m]) m = i;
    }

    int i = t - 1;
    if (i == 0) i = n;
    while (i != t){
        if (i == 0) i = n;
        if (A[m] == A[i]){
            m - i;
            break;
        }
        --i;
    }

    //cout << m << " " << t << endl;

    LL d = A[m];

    //A[m] = d * n;
    REP_1(i, n) A[i] -= d;

    i = t; while (i != m){
        if (i == 0) i = n;
        A[i] -= 1; A[m] ++;
        --i;
    }

    A[m] += d * n;
    REP_1(i, n) cout << A[i] << " ";

}


/** Micro Mezzo Macro Flation -- Overheated Economy ., Last Update: Dec. 24th 2012 **/ //{

/** Header .. **/ //{
#define LOCAL

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (int n____=(i=0,int(n));i<n____;++i)
#define FOR_C_N(i, a, b) for (int b____=(i=0,int(b);i<b____;++i)
#define DWN_C_N(i, b, a) for (int a____=(i=b-1,int(a));i>=a____;--i)
#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)

#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define REP_S(i, str) for (char*i=str;*i;++i)
#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])
#define REP_G(i, u) REP_L(i,hd[u],suc)
#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)
#define PTT pair<T, T>
#define fi first
#define se second

#define Rush for(int ____T=RD(); ____T--;)

#define Display(A, n, m) {                      \
	REP(i, n){		                            \
        REP(j, m) cout << A[i][j] << " ";       \
        cout << endl;				            \
	}						                    \
}

#define Display_1(A, n, m) {				    \
	REP_1(i, n){		                        \
        REP_1(j, m) cout << A[i][j] << " ";     \
		cout << endl;		            		\
	}						                    \
}

#pragma comment(linker, "/STACK:36777216")
//#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Python system("python main.py")
#define Pascal system("fpc main.pas")

typedef long long LL;
//typedef long double DB;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;

template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
inline LL RD(){LL x; return RD(x);}
inline DB& RF(DB &);
inline DB RF(){DB x; return RF(x);}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){char c; return RC(c);}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();}

template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
inline char& RC(char &a, char &b){RC(a), RC(b); return a;}
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}
inline void RS(char *s1, char *s2){RS(s1), RS(s2);}
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}
template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}

template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;}
template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}
template<class T> inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A))) - A.begin());return A;}

//}

/** Constant List .. **/ //{

//const int MOD = 1000000007;
int MOD = 99990001;
const int INF = 0x3f3f3f3f;
const LL INFF = 1LL << 60;
const DB EPS = 1e-9;
const DB OO = 1e15;
const DB PI = acos(-1.0); //M_PI;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//}

/** Add On .. **/ //{
// <<= '0. Nichi Joo ., //{
template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (a<b) a=b;}
template<class T> inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}
template<class T> inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
inline int ceil(int x, int y){return (x - 1) / y + 1;}
inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);}
//}

// <<= '2. Number Theory .,//{
namespace NT{
//inline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}
inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

inline int sum(int a, int b, int c){return sum(sum(a, b), c);}
inline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}
inline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}
inline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}

inline int pow(int a, int b){
    int c(1); while (b){
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

inline int pow(int a, LL b){
    int c(1); while (b){
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

template<class T> inline T pow(T a, LL b){
    T c(1); while (b){
        if (b&1) c *= a;
        a *= a, b >>= 1;
    }
    return c;
}

inline int _I(int b){
    int a = MOD, x1 = 0, x2 = 1, q;
    while (true){
        q = a / b, a %= b;
        if (!a) return (x2 + MOD) % MOD;
        DEC(x1, pdt(q, x2));

        q = b / a, b %= a;
        if (!b) return (x1 + MOD) % MOD;
        DEC(x2, pdt(q, x1));
    }
}

inline void DIV(int &a, int b){MUL(a, _I(b));}
inline int qtt(int a, int b){return pdt(a, _I(b));}

inline int phi(int n){
    int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){
        DEC(res, qtt(res, i));
        do{n /= i;} while(!(n%i));
    }
    if (n != 1)
        DEC(res, qtt(res, n));
    return res;
}

} using namespace NT;//}

/** I/O Accelerator Interface .. **/ //{
template<class T> inline T& RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
    /*char c; for (c = getchar(); c != '-' && c < '0'; c = getchar());
    if (c == '-'){x = 0; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}
    else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}*/
    return x;
}

inline DB& RF(DB &x){
    scanf("%lf", &x);
    /*char t; while ((t=getchar())==' '||t=='\n'); x = t - '0';
    while ((t=getchar())!=' '&&t!='\n'&&t!='.')x*=10,x+=t-'0';
    if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\n')l*=0.1,x += (t-'0')*l;}*/
    return x;
}

inline char* RS(char *s){
    //gets(s);
    scanf("%s", s);
    return s;
}

int Case; template<class T> inline void OT(const T &x){
    //printf("Case %d: %d\n", ++Case, x);
    //printf("%.2lf\n", x);
    //printf("%d\n", x);
    //cout << x << endl;
}
//}

//}/* .................................................................................................................................. */

const int N = 1000009;

LL A[N];
int n, m, t;

int main(){

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    RD(n, t);

    m = 1; REP_1(i, n) if (RD(A[i]) < A[m]) m = i;

    for (int i=t;;){
        if (A[m] == A[i]){m = i; break;}
        if (!--i) i = n;
    }

    for(int i=t;i!=m;){
        --A[i], ++A[m];
        if (!--i) i = n;
    }

    LL d = A[m]; REP_1(i, n) A[i] -= d; A[m] += d * n;
    REP_1(i, n) cout << A[i] << " ";
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

ll a[100000];

int main()
{

    //ifstream cin("in.txt");
    ll n, x;
    cin >> n >> x;
    x--;

    ll low = 10000000000;
    ll lowi = -1;

    ll bonus = 0;

    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];

        if (a[i] < low || (a[i] == low && (i <= x || (lowi > x))))
        {
            low = a[i];
            lowi = i;
        }
    }

    for (ll i = 0; i < n; i++)
    {
        if (i != lowi)
        {
            a[i] -= low;
            bonus += low;
        }
    }

    if (lowi <= x)
    {
        for (ll i = lowi + 1; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    } else
    {
        for (ll i = lowi + 1; i < n; i++)
        {
            a[i]--;
            bonus++;
        }

        for (ll i = 0; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    }

    a[lowi] += bonus;

    for (ll i = 0; i < n; i++)
        cout << a[i] << ' ';

    //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

ll a[100000];

int main()
{

    //ifstream cin("in.txt");
    ll n, x;
    cin >> n >> x;
    x--;

    ll low = 10000000000;
    ll lowi = -1;

    ll bonus = 0;

    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];

        if (a[i] < low)
        {
            low = a[i];
            lowi = i;
        }
    }

    for (ll i = 0; i < n; i++)
    {
        if (i != lowi)
        {
            a[i] -= low;
            bonus += low;
        }
    }

    if (lowi <= x)
    {
        for (ll i = lowi + 1; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    } else
    {
        for (ll i = lowi + 1; i < n; i++)
        {
            a[i]--;
            bonus++;
        }

        for (ll i = 0; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    }

    a[lowi] += bonus;

    for (ll i = 0; i < n; i++)
        cout << a[i] << ' ';

    //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

ll a[100000];

int main()
{

    //ifstream cin("in.txt");
    while (true) {
    ll n, x;
    cin >> n >> x;
    x--;

    ll low = 10000000000;
    ll lowi = -1;

    ll bonus = 0;

    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];

        if (a[i] < low || (a[i] == low && (i <= x || (lowi > x)))
        {
            low = a[i];
            lowi = i;
        }
    }

    for (ll i = 0; i < n; i++)
    {
        if (i != lowi)
        {
            a[i] -= low;
            bonus += low;
        }
    }

    if (lowi <= x)
    {
        for (ll i = lowi + 1; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    } else
    {
        for (ll i = lowi + 1; i < n; i++)
        {
            a[i]--;
            bonus++;
        }

        for (ll i = 0; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    }

    a[lowi] += bonus;

    for (ll i = 0; i < n; i++)
        cout << a[i] << ' ';

    //while (true) {}

    }

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

ll a[100000];

int main()
{

    //ifstream cin("in.txt");
    ios::sync_with_stdio(false);
    ll n, x;
    cin >> n >> x;
    x--;

    ll low = 10000000000;
    ll lowi = -1;

    ll bonus = 0;

    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];

        if (a[i] < low || (a[i] == low && (i <= x || (lowi > x))))
        {
            low = a[i];
            lowi = i;
        }
    }

    for (ll i = 0; i < n; i++)
    {
        if (i != lowi)
        {
            a[i] -= low;
            bonus += low;
        }
    }

    if (lowi <= x)
    {
        for (ll i = lowi + 1; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    } else
    {
        for (ll i = lowi + 1; i < n; i++)
        {
            a[i]--;
            bonus++;
        }

        for (ll i = 0; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    }

    a[lowi] += bonus;

    for (ll i = 0; i < n; i++)
        cout << a[i] << ' ';

    //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

ll a[100000];

int main()
{

    //ifstream cin("in.txt");
    ll n, x;
    cin >> n >> x;
    x--;

    ll low = 10000000000;
    ll lowi = -1;

    ll bonus = 0;

    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];

        if (a[i] < low || (a[i] == low && i <= x))
        {
            low = a[i];
            lowi = i;
        }
    }

    for (ll i = 0; i < n; i++)
    {
        if (i != lowi)
        {
            a[i] -= low;
            bonus += low;
        }
    }

    if (lowi <= x)
    {
        for (ll i = lowi + 1; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    } else
    {
        for (ll i = lowi + 1; i < n; i++)
        {
            a[i]--;
            bonus++;
        }

        for (ll i = 0; i <= x; i++)
        {
            a[i]--;
            bonus++;
        }
    }

    a[lowi] += bonus;

    for (ll i = 0; i < n; i++)
        cout << a[i] << ' ';

    //while (true) {}

}


#ifndef SOURCE_IS_SPLICED
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}
#endif

ll v[200000];
ll low[200000][18];

void run(){
  int n,fin; cin>>n>>fin; --fin; for (int i=0; i<n; i++) cin>>v[i], v[i+n]=v[i];

  for (int i=n; i--;) low[i][0]=v[i];
  for (int i=0; i+1<18; i++)
    for (int j=n; j--;)
      low[j][i+1]=min(low[j][i],low[(j+(1<<i))%n][i]);

  for (int i=0; i<n; i++){
    ll cycles=v[i];
    ll width=(n+fin-i)%n;

    if (v[i]!=cycles) continue;
    if ((i+width)%n!=fin) continue;
    if (low[0][17]<cycles) continue;

    int x=i;
    ll got=1ll<<50ll;
    for (int j=1<<17,k=17,x=(i+1)%n; j; j>>=1,--k)
      if (width&j)
        got=min(got,low[x][k]), (x+=j)%=n;

    if (got<cycles+1) continue;

    v[i]+=cycles*n+width;
    for (int j=0; j<width; j++) v[(i+j+1)%n]--;
    for (int j=0; j<n; j++) cout<<(v[j]-=cycles)<<(j+1==n?'\n':' ');
    return;
  }
  cout<<"-1"<<endl;
}


#include <bits/stdc++.h>
#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define x first
#define y second
#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)
#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))
using namespace std;
typedef long double ld; template <class _T> inline _T sqr(const _T& x) {return x * x;} template <class _T> inline string tostr(const _T& a) {ostringstream os(""); os << a; return os.str();} const ld PI = 3.1415926535897932384626433832795L; const double EPS = 1-9; char TEMPORARY_CHAR; typedef long long ll; typedef unsigned long long ull; typedef set < int > SI; typedef vector < int > VI; typedef vector < vector < int > > VVI; typedef map < string, int > MSI; typedef pair < int, int > PII; const int INF = 1e9; inline void input(int &a) {a = 0; while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){} char neg = 0; if (TEMPORARY_CHAR == '-') {neg = 1; TEMPORARY_CHAR = getchar();} while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {a = 10 * a + TEMPORARY_CHAR - '0'; TEMPORARY_CHAR = getchar();} if (neg) a = -a;} inline void out(int a) {if (!a) putchar('0'); if (a < 0) {putchar('-'); a = -a;} char s[10]; int i; for(i = 0; a; ++i) {s[i] = '0' + a % 10; a /= 10;} ford(j, i) putchar(s[j]);} inline int nxt() {in(ret); return ret;}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;
    --x;

    ll a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    ll mi = *min_element(a, a + n);

    ll sum = 0;
    ll cur = max(0ll, mi - 1);
    sum = cur * n;

    for (int i = 0; i < n; ++i)
        a[i] -= cur;

    while (a[x] != 0)
    {
        a[x]--;
        sum++;
        x--;
        if (x < 0)
            x += n;
    }
    a[x] = sum;

    for (int i = 0; i < n; ++i)
    {
        if (i)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>

using namespace std;

const int max_n = 1e5 + 15;

int n, idx, poc, add, val;
long long niz[max_n];

int main()
{
  cin >> n >> idx;
  poc = --idx;
  for (int i = 0; i < n; i++) cin >> niz[i];
  for (int i = idx - 1; i != idx; i = (i - 1 + n) % n)
    if (niz[i] < niz[poc]) poc = i;
  val = niz[poc];
  for (int i = 0; i < n; i++) niz[i] -= val, add += val;
  for (int i = idx; i != poc; i = (i - 1 + n) % n) niz[i]--, add++;
  niz[poc] += add;
  for (int i = 0; i < n; i++) cout << niz[i] << " ";
  return 0;
}


#include <iostream>

using namespace std;

const int max_n = 1e5 + 15;

int n, idx, poc, add, val, niz[max_n];

int main()
{
  cin >> n >> idx;
  poc = --idx;
  for (int i = 0; i < n; i++) cin >> niz[i];
  for (int i = idx - 1; i != idx; i = (i - 1 + n) % n)
    if (niz[i] < niz[poc]) poc = i;
  val = niz[poc];
  for (int i = 0; i < n; i++) niz[i] -= val, add += val;
  for (int i = idx; i != poc; i = (i - 1 + n) % n) niz[i]--, add++;
  niz[poc] += add;
  for (int i = 0; i < n; i++) cout << niz[i] << " ";
  return 0;
}


#include <iostream>

using namespace std;

const int max_n = 1e5 + 15;

int n, idx, poc, val;
long long add, niz[max_n];

int main()
{
  cin >> n >> idx;
  poc = --idx;
  for (int i = 0; i < n; i++) cin >> niz[i];
  for (int i = idx - 1; i != idx; i = (i - 1 + n) % n)
    if (niz[i] < niz[poc]) poc = i;
  val = niz[poc];
  for (int i = 0; i < n; i++) niz[i] -= val, add += val;
  for (int i = idx; i != poc; i = (i - 1 + n) % n) niz[i]--, add++;
  niz[poc] += add;
  for (int i = 0; i < n; i++) cout << niz[i] << " ";
  return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
//#define ABS(a) ((a)>0?(a):(-(a)))
//#define MIN(a,b) ((a)<(b)?(a):(b))
//#define MAX(a,b) ((a)>(b)?(a):(b))
//#define CHKMIN(a,b) do{__typeof(a) _chkmin_tmp_ = b; if(_chkmin_tmp_ < a) a = _chkmin_tmp_;}while(0)
//#define CHKMAX(a,b) do{__typeof(a) _chkmax_tmp_ = b; if(_chkmax_tmp_ > a) a = _chkmax_tmp_;}while(0)
//#define SWAP(a,b) do{__typeof(a) _swap_tmp_ = a; a = b; b = _swap_tmp_;}while(0)
template<typename T>
inline T ABS(T a) { return a > 0 ? a : -a; }
template<typename T>
inline T MIN(T a, T b) { return a < b ? a : b; }
template<typename T>
inline T MAX(T a, T b) { return a > b ? a : b; }
template<typename T>
inline T CHKMIN(T &a, T b) { if(a > b) a = b; return a; }
template<typename T>
inline T CHKMAX(T &a, T b) { if(a < b) a = b; return a; }
template<typename T>
inline void SWAP(T &a, T &b) { static T c = a; a = b; b = c; }
template<typename T>
T bsrch(T beg, T end, std::function<int(T)> f) {
	T mid;
	while(beg < end) {
		mid = beg + (end - beg) / 2;
		if(f(mid)) {
			end = mid;
		} else {
			beg = mid + 1;
		}
	}
	return end;
}
typedef __int64 ll;
typedef unsigned __int64 ull;
using namespace std;
int n, x;
ull in[200000], mins;
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while(cin >> n >> x) {
		--x;
		REP(i, 0, n) cin >> in[i];
		mins = in[0];
		REP(i, 1, n) CHKMIN(mins, in[i]);
		int t = x;
		ll ans = 0;
		do {
			if(in[t] == mins) break;
			--in[t]; ++ans;
			t = (t + n - 1) % n;
		} while(t != x);
		REP(i, 0, n) {
			in[i] -= mins;
			ans += mins;
		}
		//cout << mins << ' ' << t << ' ' << in[t] << ' ' << ans << endl;
		in[t] = ans;
		REP(i, 0, n) {
			cout << in[i];
			if(i == n - 1) cout << endl;
			else cout << ' ';
		}
	}
	return 0;
}


#define TASKNAME "text"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>

#define EPS 1e-9
#define INF int(2e9)
#define INFLONG (long long)(1e18)
#define sqr(a) ((a) * (a))
#define all(a) (a).begin(), (a).end()
#define zero(a) memset(a, 0, sizeof(a))
#define abs(a) (((a) < 0) ? -(a) : (a))
#define sz(a) (int)a.size()
#define fst first
#define snd second
#define y1 osrughosduvgarligybakrybrogvba
#define y0 aosfigdalrowgyalsouvgrlvygalri
#define mp make_pair
#define pb push_back
#define next dlkjdslfkdj
#define prev dsdflksdfjl
#define hash lkdfjldskfj
#define pi 3.1415926535897932384626433832795
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <bool> vb;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef vector <pii> vpii;

struct ST
{
  int n;
  vi t;

  ST()
  {
    t.clear();
    n = 0;
  }

  ST(vi &a)
  {
    int _n = sz(a);
    n = 1;
    while (n < _n)
      n <<= 1;
    t.resize(n << 1);
    for (int i = n; i < (n << 1); i++)
      t[i] = i < n + _n ? a[i - n] : INF;
    for (int i = n - 1; i > 0; i--)
      t[i] = min(t[i << 1], t[(i << 1) + 1]);
  }

  inline int get(int v, int a, int b, int l, int r)
  {
    if (a > r || l > b)
      return INF;
    if (l <= a && b <= r)
      return t[v];
    int m = (a + b) >> 1;
    return min(get(v << 1, a, m, l, r), get((v << 1) + 1, m + 1, b, l, r));
  }

  inline int get(int l, int r)
  {
    if (l > r)
      return INF;
    return get(1, n, 2 * n - 1, l + n, r + n);
  }
};

int n, x;

int main()
{
  #ifdef LocalHost
    freopen(TASKNAME".in", "r", stdin);
    freopen(TASKNAME".out", "w", stdout);
  #endif
  while (scanf("%d%d", &n, &x) >= 1)
  {
    --x;
    vi a(n);
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);
    ST tree = ST(a);
    for (int i = 0; i < n; i++)
    {
      if (i == x)
      {
        int k = a[i];
        ll na = (ll)n * (ll)k;
        int m = min(tree.get(0, x - 1), tree.get(x + 1, n - 1));
        if (m >= k)
        {
          for (int j = 0; j < i; j++)
            printf("%d ", a[j] - k);
          printf("%I64d ", na);
          for (int j = i + 1; j < n; j++)
            printf("%d ", a[j] - k);
          puts("");
          break;
        }
      }
      else
      if (i > x)
      {
        int y = (n - i - 1) + 1 + x;
        int k = a[i];
        ll na = (ll)n * (ll)k + (ll)y;
        int m1 = tree.get(x + 1, i - 1);
        int m2 = min(tree.get(i + 1, n - 1), tree.get(0, x));
        if (m1 >= k && m2 >= k + 1)
        {
          for (int j = 0; j <= x; j++)
            printf("%d ", a[j] - k - 1);
          for (int j = x + 1; j < i; j++)
            printf("%d ", a[j] - k);
          printf("%I64d ", na);
          for (int j = i + 1; j < n; j++)
            printf("%d ", a[j] - k - 1);
          puts("");
          break;
        }
      }
      else
      {
        int y = x - i;
        int k = a[i];
        ll na = (ll)n * (ll)k + (ll)y;
        int m1 = tree.get(i + 1, x);
        int m2 = min(tree.get(0, i - 1), tree.get(x + 1, n - 1));
        if (m1 >= k + 1 && m2 >= k)
        {
          for (int j = 0; j < i; j++)
            printf("%d ", a[j] - k);
          printf("%I64d ", na);
          for (int j = i + 1; j <= x; j++)
            printf("%d ", a[j] - k - 1);
          for (int j = x + 1; j < n; j++)
            printf("%d ", a[j] - k);
          puts("");
          break;
        }
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pi acos(-1.0)
#define EPS 1e-9
typedef long long ll;

using namespace std;

ll v[100009];
int main()
{
	int n,x;cin>>n>>x;
	for(int i=0;i<n;i++)cin>>v[i];
	ll cnt=0;
	for(int i=x-1;i>=0;i--){
		if(v[i]==0){
			v[i]=cnt;
			for(int j=0;j<n;j++)cout<<v[j]<<" ";
			cout<<"\n";
			return 0;
		}
		v[i]--;cnt++;
	}
	int pos=-1;ll mn=INT_MAX;
	for(int i=n-1;i>=0;i--){
		if(v[i]<mn)mn=v[i],pos=i;
	}
	ll tmp=(v[pos]*(ll)n);
	cnt+=tmp;
	cnt+=(ll)((n-pos)-1);
	v[pos]=cnt;
	for(int i=0;i<n;i++){
		if(i==pos){cout<<v[i]<<" ";continue;}
		ll rem=tmp;
		if(i>pos)rem++;
		cout<<v[i]-rem<<" ";
	}
	cout<<"\n";
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pi acos(-1.0)
#define EPS 1e-9
typedef long long ll;

using namespace std;

ll v[100009];
int main()
{
	int n,x;cin>>n>>x;
	for(int i=0;i<n;i++)cin>>v[i];
	ll cnt=0;
	for(int i=x-1;i>=0;i--){
		if(v[i]==0){
			v[i]=cnt;
			for(int j=0;j<n;j++)cout<<v[j]<<" ";
			cout<<"\n";
			return 0;
		}
		v[i]--;cnt++;
	}
	int pos=-1;ll mn=INT_MAX;
	for(int i=n-1;i>=0;i--){
		if(v[i]<mn)mn=v[i],pos=i;
	}
	cnt+=(v[pos]*(ll)n);
	cnt+=(ll)((n-pos)-1);
	ll rem=v[pos];
	v[pos]=cnt;
	for(int i=0;i<n;i++){
		if(i==pos){cout<<v[i]<<" ";continue;}
		cout<<v[i]-(rem+(i>pos))<<" ";
	}
	cout<<"\n";
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int a[100100];
int main() {
  int n,x; cin >> n >> x; x--;
  for (int i = 0; i < n; i++) {
    int y; scanf("%d",&y);
    a[i]=y;
  }
  int mn = inf;
  int where = -1;
  for (int i = (x+n-1)%n; ; i=(i+n-1)%n) {
    if (a[i] < mn ) {
      mn = a[i];
      where = i;
    }
    if (i==x) {
      break;
    }
  }
  int64 z = 0;
  for (int i = x%n; i != where; i=(i+n-1)%n) {
    a[i]--;
    z++;
  }
  z += mn*n;
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    if (i == where) {
      cout << z;
    } else {
      printf("%d",a[i]-mn);
    }
  }
  puts("");
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int a[100100];
int main() {
  int64 n,x; cin >> n >> x; x--;
  for (int i = 0; i < n; i++) {
    int y; scanf("%d",&y);
    a[i]=y;
  }
  int64 mn = inf;
  int where = -1;
  for (int i = x; ; i=(i+n-1)%n) {
    if (a[i] < mn) {
      mn = a[i];
      where = i;
    }
    if (i==((x+1)%n)) {
      break;
    }
  }
  int64 z = 0;
  for (int i = (where+1)%n; ; i=(i+1)%n) {
    a[i]--;
    if (a[i] < mn) {
      mn = a[i];
    }
    z++;
    if (i == x) {
      break;
    }
  }
  z += mn*n;
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    if (i == where) {
      cout << z;
    } else {
      printf("%d",a[i]-mn);
    }
  }
  puts("");
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int a[100100];
int main() {
  int n,x; cin >> n >> x; x--;
  for (int i = 0; i < n; i++) {
    int y; scanf("%d",&y);
    a[i]=y;
  }
  int mn = inf;
  int where = -1;
  for (int i = x; ; i=(i+n-1)%n) {
    if (a[i] < mn) {
      mn = a[i];
      where = i;
    }
    if (i==((x+1)%n)) {
      break;
    }
  }
  int64 z = 0;
  for (int i = (where+1)%n; ; i=(i+1)%n) {
    a[i]--;
    if (a[i] < mn) {
      mn = a[i];
    }
    z++;
    if (i == x) {
      break;
    }
  }
  z += mn*n;
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    if (i == where) {
      cout << z;
    } else {
      printf("%d",a[i]-mn);
    }
  }
  puts("");
  return 0;
}


/*
 * c.cpp
 *
 *  Created on: Feb 13, 2015
 *      Author: Hassan
 */
#include <bits/stdc++.h>

using namespace std;

typedef long long 						ll;
typedef unsigned long long 				ull;
typedef pair<int,int> 					ii;
typedef vector<int> 					vi;
typedef vector<vector<int> > 			vvi;
typedef vector<pair<int,int> > 			vii;
typedef vector<vector<pair<int,int> > > vvii;
typedef complex<double> 				point;

#define MAX_LONG           9223372036854775807
#define MIN_LONG          -9223372036854775808
#define EPS                1e-12
#define MOD       		   ((int)(1e9)+7)
#define Inff               (int)(1e8)
#define pb                 push_back
#define mp                 make_pair
#define X		           real()
#define Y		  		   imag()
#define polar(r,t) 		   ((r)*exp(point(0,(t))))
#define length(a)  		   hypot((a).X,(a).Y)
#define angle(a)           atan2((a).Y,(a).X)
#define vec(a,b) 		   ((b)-(a))
#define dot(a,b) 		   ((conj(a)*(b)).real())
#define cross(a,b) 		   ((conj(a)*(b)).imag())
#define length_sqr(a)      dot(a,a)
#define rotate(v,t) 	   ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define reflect(v,m)       (conj((v)/(m))*(m))

const int N = (1e5) + 7;

int n, x;

ll a[N];

int main(){
	scanf("%d %d",&n,&x);
	ll mini = 1LL<<40;
	for(int i = 0 ; i < n ; ++i) {
		scanf("%I64d",a+i);
		mini = min(mini,a[i]);
	}
	for(int i = 0 ; i < n ; ++i)
		a[i] -= mini;
	ll t = mini*n;
	--x;
	while(a[x]) {
		--a[x];
		++t;
		--x;
		if(x < 0) x = n-1;
	}
	a[x] = t;
	for(int i = 0 ; i < n ; ++i)
		printf("%I64d ",a[i]);
	return 0;
}


#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main() {
    long long n, x, a[100001];
    cin>>n>>x;
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }
    long long sum=0;
    long long i=x-1;
    long long min_ =10000000000;
    long long idx = x;
    for (int i=0;i<n;i++) {
        if (idx>=n) {
            idx =0;
        }
        if (a[idx]<=min_) {
            min_=a[idx];
        }
        idx++;
    }

    if (min_>=2) {
        for (int i=0;i<n;i++) {
            sum+=min_-1;
            a[i]-=min_-1;
        }
    }
    i = x-1;
    while (true) {
        if (a[i]>0) {
            sum+= 1;
            a[i]-= 1;
            i=i-1;
            if (i==-1) {
                i=n-1;
            }
        } else {
            a[i] = sum;
            break;
        }
    }
    for (int i=0;i<n;i++) {
        cout<<a[i]<< " ";
    }
    cout<<endl;

}


#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main() {
    long long n, x, a[100001];
    cin>>n>>x;
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }
    long long sum=0;
    long long i=x-1;
    while (true) {
        if (a[i]>0) {
            sum++;
            a[i]--;
            i=i-1;
            if (i==-1) {
                i=n-1;
            }
        } else {
            a[i] = sum;
            break;
        }
    }
    for (int i=0;i<n;i++) {
        cout<<a[i]<< " ";
    }
    cout<<endl;

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <set>
#include <map>
#include <sstream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
ll G(ll a,ll b){if(b==0)return a;return G(b,a%b);}
ll a[100000+10];
int main(){
	ios_base::sync_with_stdio(false);
	ll n,l,id=-1,mn=-1,tmp=0;
	cin>>n>>l;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		int j=(i+l)%n;
		if(mn==-1 || mn>=a[j]){
			id=j;
			mn=a[j];
		}
	}
	for(int i=0;i<n;i++)a[i]-=mn;
	for(int i=l-1;a[i];i=(i+n-1)%n)a[i]--,tmp++;
	a[id]=n*mn+tmp;
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
}


#include<algorithm>
#include<iostream>
using	namespace	std;
int	main(void)
{
	long	long	t,Q[100000],*p;
	for(long	n,i,j;cin>>n>>j;cout<<'\n'){
		for(j+=i=-1;n^++i;cin>>Q[i]);
		t=Q[i=(p=min_element(Q,n+Q))-Q];
		for(long	long	&e:Q)	e-=t;
		for(*p=n*t;++*p,--Q[i=(1+i)%n],j^i;);
		for(i=0;cout<<Q[i],n^++i;cout<<' ');
	}
	return	0;
}


#include<iostream>
using	namespace	std;
int	main(void)
{
	long	long	t,Q[100000];
	for(long	n,i,j,k;cin>>n>>j;cout<<'\n'){
		for(j+=i=-1;n^++i;cin>>Q[i]);
		for(k=i=j;j^(i=(n-1+i)%n);)	if(Q[k]>Q[i])	k=i;
		t=Q[i=k];
		for(long	long	&e:Q)	e-=t;
		for(Q[k]=n*t;j^i;--Q[i=(1+i)%n])	++Q[k];
		for(i=0;cout<<Q[i],n^++i;cout<<' ');
	}
	return	0;
}


#include<algorithm>
#include<iostream>
using	namespace	std;
int	main(void)
{
	long	long	t,Q[100000],*p;
	for(long	n,i,j;cin>>n>>j;cout<<'\n'){
		for(j+=i=-1;n^++i;cin>>Q[i]);
		t=Q[i=(p=min_element(Q,n+Q))-Q];
		for(long	long	&e:Q)	e-=t;
		for(*p=n*t;j^i;--Q[i=(1+i)%n])	++*p;
		for(i=0;cout<<Q[i],n^++i;cout<<' ');
	}
	return	0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n, x; cin >> n >> x;

    vector<int> balls(n);

    for ( int i=0; i<n; i++ ){
        cin >> balls[i];
    }

    int p = x - 1;
    int d = 0;

    while (true){
//      cout << "p is " << p << " | balls[p]: " << balls[p] << endl;
        if ( balls[p] == 0 ){
            balls[p] = d;
            break;
        }
        balls[p]--;
        p = (p - 1 + n) % n;
//      cout << "p is now: " << p << " | balls[p]: " << balls[p] << endl;
        d++;
    };

    cout << balls[0];
    for ( int i=1; i<n; i++ ){
        cout << " " << balls[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n, x; cin >> n >> x;

    vector<long long> balls(n);

    for ( int i=0; i<n; i++ ){
        cin >> balls[i];
    }

    long long m = balls[0];
    for ( int i=1; i<n; i++ ){
        if ( balls[i] < m ){
            m = balls[i];
        }
    }

    bool faster = true;
    if ( m >= 2 ){
        m--;
        for ( int i=0; i<n; i++ ){
            balls[i] -= m;
        }
        faster = false;
    }

    int p = x - 1;
    int d = 0;

    while (true){
//      cout << "p is " << p << " | balls[p]: " << balls[p] << endl;
        if ( balls[p] == 0 ){
            balls[p] = d;
            if ( !faster ){
                balls[p] += (m*n);
            }
            break;
        }
        balls[p]--;
        p = (p - 1 + n) % n;
//      cout << "p is now: " << p << " | balls[p]: " << balls[p] << endl;
        d++;
    };

    cout << balls[0];
    for ( int i=1; i<n; i++ ){
        cout << " " << balls[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n, x; cin >> n >> x;

    vector<int> balls(n);

    for ( int i=0; i<n; i++ ){
        cin >> balls[i];
    }

    int m = balls[0];
    for ( int i=1; i<n; i++ ){
        if ( balls[i] < m ){
            m = balls[i];
        }
    }

    if ( m >= 2 ){
        m--;
        for ( int i=0; i<n; i++ ){
            balls[i] -= m;
        }
    }

    int p = x - 1;
    int d = 0;

    while (true){
//      cout << "p is " << p << " | balls[p]: " << balls[p] << endl;
        if ( balls[p] == 0 ){
            balls[p] = d;
            if ( m >= 1 ){
                balls[p] += (m*n);
            }
            break;
        }
        balls[p]--;
        p = (p - 1 + n) % n;
//      cout << "p is now: " << p << " | balls[p]: " << balls[p] << endl;
        d++;
    };

    cout << balls[0];
    for ( int i=1; i<n; i++ ){
        cout << " " << balls[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n, x; cin >> n >> x;

    vector<int> balls(n);

    for ( int i=0; i<n; i++ ){
        cin >> balls[i];
    }

    int m = balls[0];
    for ( int i=1; i<n; i++ ){
        if ( balls[i] < m ){
            m = balls[i];
        }
    }

    bool faster = true;
    if ( m >= 2 ){
        m--;
        for ( int i=0; i<n; i++ ){
            balls[i] -= m;
        }
        faster = false;
    }

    int p = x - 1;
    int d = 0;

    while (true){
//      cout << "p is " << p << " | balls[p]: " << balls[p] << endl;
        if ( balls[p] == 0 ){
            balls[p] = d;
            if ( !faster ){
                balls[p] += (m*n);
            }
            break;
        }
        balls[p]--;
        p = (p - 1 + n) % n;
//      cout << "p is now: " << p << " | balls[p]: " << balls[p] << endl;
        d++;
    };

    cout << balls[0];
    for ( int i=1; i<n; i++ ){
        cout << " " << balls[i];
    }
    cout << endl;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
//#define ABS(a) ((a)>0?(a):(-(a)))
//#define MIN(a,b) ((a)<(b)?(a):(b))
//#define MAX(a,b) ((a)>(b)?(a):(b))
//#define CHKMIN(a,b) do{__typeof(a) _chkmin_tmp_ = b; if(_chkmin_tmp_ < a) a = _chkmin_tmp_;}while(0)
//#define CHKMAX(a,b) do{__typeof(a) _chkmax_tmp_ = b; if(_chkmax_tmp_ > a) a = _chkmax_tmp_;}while(0)
//#define SWAP(a,b) do{__typeof(a) _swap_tmp_ = a; a = b; b = _swap_tmp_;}while(0)
template<typename T>
inline T ABS(T a) { return a > 0 ? a : -a; }
template<typename T>
inline T MIN(T a, T b) { return a < b ? a : b; }
template<typename T>
inline T MAX(T a, T b) { return a > b ? a : b; }
template<typename T>
inline T CHKMIN(T &a, T b) { if(a > b) a = b; return a; }
template<typename T>
inline T CHKMAX(T &a, T b) { if(a < b) a = b; return a; }
template<typename T>
inline void SWAP(T &a, T &b) { static T c = a; a = b; b = c; }
template<typename T>
T bsrch(T beg, T end, std::function<int(T)> f) {
	T mid;
	while(beg < end) {
		mid = beg + (end - beg) / 2;
		if(f(mid)) {
			end = mid;
		} else {
			beg = mid + 1;
		}
	}
	return end;
}
typedef __int64 ll;
typedef unsigned __int64 ull;
using namespace std;
int n, x;
ull in[200000], mins;
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while(cin >> n >> x) {
		--x;
		REP(i, 0, n) cin >> in[i];
		mins = in[0];
		REP(i, 1, n) CHKMIN(mins, in[i]);
		int t = x;
		ll ans = 0;
		do {
			if(in[t] == mins) break;
			--in[t]; ++ans;
			t = (t + n - 1) % n;
		} while(t != x);
		REP(i, 0, n) {
			in[i] -= mins;
			ans += mins;
		}
		//cout << mins << ' ' << t << ' ' << in[t] << ' ' << ans << endl;
		in[t] = ans;
		REP(i, 0, n) {
			cout << in[i];
			if(i == n - 1) cout << endl;
			else cout << ' ';
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int box[MAXN];
int minFromLast[MAXN];
int minFromEnd[MAXN];
int minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] - (lowest + 1) <= 0)
				continue ;
			int firstBox = lowest * N + last - i;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int firstBox = lowest * N;
		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	if (box[i] == lowest)
	{
		int firstBox = lowest * N + last + N - i;

		if (minFromEnd[i + 1] - (lowest + 1) <= 0)
			continue ;

		if (minFromStart[last] - (lowest + 1) <= 0)
			continue ;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	while (1);

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int box[MAXN];
int minFromLast[MAXN];
int minFromEnd[MAXN];
int minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] < box[i] + 1)
				continue ;
			int firstBox = box[i] * N + last - i;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int firstBox = lowest * N;
		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	if (box[i] == lowest)
	{
		int firstBox = lowest * N + last + N - i;

		if (minFromEnd[i + 1] < lowest + 1)
			continue ;

		if (minFromStart[last] < lowest + 1)
			continue ;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int64 box[MAXN];
int64 minFromLast[MAXN];
int64 minFromEnd[MAXN];
int64 minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int64 lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] - (lowest + 1) < 0)
				continue ;
			int64 firstBox = lowest * N + last - i;

//			cout << "Start at " << i + 1 << endl;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int64 firstBox = lowest * N;

//		cout << "Start at " << last + 1 << endl;

		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N] = 1LL << 60;
	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	if (box[i] == lowest)
	{
		int64 firstBox = lowest * N + last + N - i;

		if (minFromEnd[i + 1] - (lowest + 1) < 0)
			continue ;

		if (minFromStart[last] - (lowest + 1) < 0)
			continue ;

//		cout << "Start at " << i + 1 << endl;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int64 box[MAXN];
int64 minFromLast[MAXN];
int64 minFromEnd[MAXN];
int64 minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int64 lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] - (lowest + 1) < 0)
				continue ;
			int firstBox = lowest * N + last - i;

//			cout << "Start at " << i + 1 << endl;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int64 firstBox = lowest * N;

//		cout << "Start at " << last + 1 << endl;

		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N] = 1LL << 60;
	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	if (box[i] == lowest)
	{
		int64 firstBox = lowest * N + last + N - i;

		if (minFromEnd[i + 1] - (lowest + 1) < 0)
			continue ;

		if (minFromStart[last] - (lowest + 1) < 0)
			continue ;

//		cout << "Start at " << i + 1 << endl;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int64 box[MAXN];
int64 minFromLast[MAXN];
int64 minFromEnd[MAXN];
int64 minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int64 lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] - (lowest + 1) <= 0)
				continue ;
			int firstBox = lowest * N + last - i;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int64 firstBox = lowest * N;
		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	if (box[i] == lowest)
	{
		int64 firstBox = lowest * N + last + N - i;

		if (minFromEnd[i + 1] - (lowest + 1) <= 0)
			continue ;

		if (minFromStart[last] - (lowest + 1) <= 0)
			continue ;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int64 box[MAXN];
int64 minFromLast[MAXN];
int64 minFromEnd[MAXN];
int64 minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int64 lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] - (lowest + 1) <= 0)
				continue ;
			int firstBox = lowest * N + last - i;

//			cout << "Start at " << i + 1 << endl;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int64 firstBox = lowest * N;

//		cout << "Start at " << last + 1 << endl;

		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N] = 1LL << 60;
	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	if (box[i] == lowest)
	{
		int64 firstBox = lowest * N + last + N - i;

		if (minFromEnd[i + 1] - (lowest + 1) <= 0)
			continue ;

		if (minFromStart[last] - (lowest + 1) <= 0)
			continue ;

//		cout << "Start at " << i + 1 << endl;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef long long int64;

#define SZ(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)n; ++i)

const int
	MAXN =  1 << 17;

int N, last;
int box[MAXN];
int minFromLast[MAXN];
int minFromEnd[MAXN];
int minFromStart[MAXN];

int main()
{
	ios::sync_with_stdio(0);

	cin >> N >> last;
	--last;

	REP(i, N)
		cin >> box[i];

	int lowest = *min_element(box, box + N);

	minFromLast[last] = box[last];
	for (int i = last - 1; i >= 0; --i)
		minFromLast[i] = min(minFromLast[i + 1], box[i]);

	REP(i, last)
		if (box[i] == lowest)
		{
			if (minFromLast[i + 1] < box[i] + 1)
				continue ;
			int firstBox = box[i] * N + last - i;

			REP(j, N)
			{
				if (j == i)
					cout << firstBox << " ";
				else
					cout << box[j] - lowest - (j > i && j <= last) << " ";
			}
			cout << endl;

			return 0;
		}

	if (box[last] == lowest)
	{
		int firstBox = lowest * N;
		REP(j, N)
		{
			if (j == last)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest << " ";
		}
		cout << endl;

		return 0;
	}

	minFromEnd[N - 1] = box[N - 1];
		for (int i = N - 2; i >= 0; --i)
			minFromEnd[i] = min(minFromEnd[i + 1], box[i]);

	minFromStart[0] = box[0];
		for (int i = 1; i < N; ++i)
			minFromStart[i] = min(minFromStart[i - 1], box[i]);

	for (int i = last + 1; i < N; ++i)
	{
		int firstBox = box[i] * N + last + N - i;

		if (minFromEnd[i + 1] < lowest + 1)
			continue ;

		if (minFromStart[last] < lowest + 1)
			continue ;

		REP(j, N)
		{
			if (j == i)
				cout << firstBox << " ";
			else
				cout << box[j] - lowest - (j <= last || j > i) << " ";
		}
		cout << endl;

		return 0;
	}

	return 0;
}


#include <iostream>
#include <string>
#include<stdio.h>
#include <cstdlib>

#define int64 unsigned long long

using namespace std;

int64 arr[100001];

int main()
{
    int64 N;
    int x;
    int64 min = 0xffffffff;
    int im;

    cin >> N >> x;
    x--;

    int dx = 1000000;
    for( int i = 0; i < N; i++)
    {
        cin >>  arr[i];
        if( arr[i] < min )
        {
            min = arr[i];
            im = i;
            dx = 1000000;
        }
        else if( arr[i] == min)
        {
            if( (x-i+N)%N < dx)
            {
                min = arr[i];
                im = i;
                dx = (x-i+N)%N;
            }
        }
    }

    for(int i = 0; i < N; i++)
    {
        arr[i] -= min;
    }

    for( int i = x; i != im; i = (i-1+N)%N )
    {
        arr[i]--;
    }

    arr[im] = min*N + (x-im+N)%N;

    for(int i = 0; i < N; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;

    return 0;
}


#include <iostream>
#include <string>
#include<stdio.h>
#include <cstdlib>

#define int64 unsigned long long

using namespace std;

int64 arr[100001];

int main()
{
    int64 N;
    int x;
    int64 min = 0xffffffff;
    int im;

    scanf("%I64d %d", &N, &x);
    x--;

    for( int i = 0; i < N; i++)
    {
        scanf("%I64d", &arr[i]);
        if( arr[i] < min)
        {
            min = arr[i];
            im = i;
        }
    }

    for(int i = 0; i < N; i++)
    {
        arr[i] -= min;
    }

    int i = x;
    int k = 0;
    while(1)
    {
        if( arr[i] == 0)
            break;
        arr[i]--;
        k++;
        i = (i-1+N)%N;
    }

    arr[i] = min*N + k;

    for(int i = 0; i < N; i++)
    {
        printf("%I64d ", arr[i]);
    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <string>
#include<stdio.h>
#include <cstdlib>

#define int64 unsigned long long

using namespace std;

int64 arr[100001];

int main()
{
    int64 N;
    int x;
    int64 min = 0xffffffff;
    int im;

    cin >> N >> x;
    x--;

    int dx = 1000000;
    for( int i = 0; i < N; i++)
    {
        cin >>  arr[i];
        if( arr[i] < min )
        {
            min = arr[i];
            im = i;
        }
        else if( arr[i] == min)
        {
            if( (x-i+N)%N < dx)
            {
                min = arr[i];
                im = i;
                dx = (x-i+N)%N;
            }
        }
    }

    for(int i = 0; i < N; i++)
    {
        arr[i] -= min;
    }

    for( int i = x; i != im; i = (i-1+N)%N )
    {
        arr[i]--;
    }

    arr[im] = min*N + (x-im+N)%N;

    for(int i = 0; i < N; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;

    return 0;
}


#include <iostream>
#include <string>
#include<stdio.h>
#include <cstdlib>

#define int64 unsigned long long

using namespace std;

int64 arr[100001];

int main()
{
    int64 N;
    int x;
    int64 min = 0xffffffff;
    int im;

    cin >> N >> x;
    x--;

    for( int i = 0; i < N; i++)
    {
        cin >>  arr[i];
        if( arr[i] < min )
        {
            min = arr[i];
            im = i;
        }
    }

    for(int i = 0; i < N; i++)
    {
        arr[i] -= min;
    }

    for( int i = x; i != im; i = (i-1+N)%N )
    {
        arr[i]--;
    }

    arr[im] = min*N + (x-im+N)%N;

    for(int i = 0; i < N; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;

    return 0;
}


#include <iostream>
#include <string>
#include<stdio.h>
#include <cstdlib>

#define int64 unsigned long long

using namespace std;

int64 arr[100001];

int main()
{
    int64 N;
    int x;
    int64 min = 0xffffffff;
    int im;

    scanf("%I64d %d", &N, &x);
    x--;

    int dx = 1000000;
    for( int i = 0; i < N; i++)
    {
        cin >>  arr[i];
        if( arr[i] < min )
        {
            min = arr[i];
            im = i;
            dx = (x-i+N)%N;
        }
        else if( arr[i] == min)
        {
            if( (x-i+N)%N < dx)
            {
                min = arr[i];
                im = i;
                dx = (x-i+N)%N;
            }
        }
    }

    for(int i = 0; i < N; i++)
    {
        arr[i] -= min;
    }

    for( int i = x; i != im; i = (i-1+N)%N )
    {
        arr[i]--;
    }

    arr[im] = min*N + (x-im+N)%N;

    for(int i = 0; i < N; i++)
    {
        printf("%I64d ", arr[i]);
    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <string>
#include<stdio.h>
#include <cstdlib>

#define int64 unsigned long long

using namespace std;

int64 arr[100001];

int main()
{
    int64 N;
    int x;
    int64 min = 0xffffffff;
    int im;

    scanf("%I64d %d", &N, &x);
    x--;

    int dx = 1000000;
    for( int i = 0; i < N; i++)
    {
        cin >>  arr[i];
        if( arr[i] < min )
        {
            min = arr[i];
            im = i;
            dx = 1000000;
        }
        else if( arr[i] == min)
        {
            if( (x-i+N)%N < dx)
            {
                min = arr[i];
                im = i;
                dx = (x-i+N)%N;
            }
        }
    }

    for(int i = 0; i < N; i++)
    {
        arr[i] -= min;
    }

    for( int i = x; i != im; i = (i-1+N)%N )
    {
        arr[i]--;
    }

    arr[im] = min*N + (x-im+N)%N;

    for(int i = 0; i < N; i++)
    {
        printf("%I64d ", arr[i]);
    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

using ull = unsigned long long;

int main(void) {
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<ull> b (n);
    for (int i = 0; i < n; ++i)
    {
        cin >> b[i];
    }
    ull mini = b[0];
    for(ull y : b) {
        if(y < mini)
            mini = y;
    }
    int index = x - 1;
    int len = 0;
    for (int i = 0; i < n; ++i)
    {
        if(b[index] == mini)
            break;
        len++;
        b[index]--;
        index--;
        if(index < 0)
            index = n - 1;
    }
    for (int i = 0; i < n; ++i)
    {
        b[i] -= mini;
    }
    b[index] = len + n * mini;
    cout << b[0];
    for (int i = 1; i < n; ++i)
    {
        cout << " " << b[i];
    }
    cout << endl;
}


#include <cassert>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <complex>
using namespace std;

// begin insert defines
#define ALL(a) (a).begin(),(a).end()
#define Rep(i,n) for(int n_ = (n), i = 0; i< n_; ++i)
template <class T> void PV(T x) {for(__typeof__((x).begin()) i = (x).begin(); i != (x).end(); ++i) cout << *i << " "; cout << endl;}
template <class T> inline void gmin (T &a, T b) {if (b < a) a = b;}
#define VR vector
typedef long long ll;

// end insert defines

int main(int argc, char *argv[])
{
    int n, x;
    cin >> n >> x;
    VR<ll> a(n);
    for (auto &ai: a) cin >> ai;
    x--;
    reverse(ALL(a));
    rotate(a.begin(), a.end() - x - 1, a.end());
    ll mini = a[0];
    for (auto &ai: a) gmin(mini, ai);
    for (auto &ai: a) ai -= mini;
    ll na = mini * n;
    Rep(i, n) {
        if (a[i] == 0) {
            a[i] = na;
            break;
        }
        a[i]--;
        na++;
    }
    rotate(a.begin(), a.begin() + (x + 1) % n, a.end());
    reverse(ALL(a));
    PV(a);
    return 0;
}


#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <complex>
#include <numeric>
#include <valarray>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define inf 1061109567
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define mem(x,a) memset(x,a,sizeof(x))
#define rep(i,n) for(int i(0),_n(n);i<_n;++i)
#define repi(i,a,b) for(int i(a),_b(b);i<_b;++i)
#define repe(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define len(x) ((int)(x.size()))

#define DEBUG 1
#if DEBUG && !ONLINE_JUDGE
	#define debug(args...) (Debugger()) , args
	class Debugger { public: Debugger(const std::string& _separator = ", ") : first(true), separator(_separator){} template<typename ObjectType> Debugger& operator , (const ObjectType& v) { if(!first) std::cerr << separator; std::cerr << v; first = false; return *this; } ~Debugger() { std::cerr << endl;} private: bool first; std::string separator; }; template <typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; } template<typename T> inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v) { bool first = true; os << "["; for(unsigned int i = 0; i < v.size(); i++) { if(!first) os << ", "; os << v[i]; first = false; } return os << "]"; } template<typename T> inline std::ostream &operator << (std::ostream & os,const std::set<T>& v) { bool first = true; os << "["; for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if(!first) os << ", "; os << *ii; first = false; } return os << "]"; } template<typename T1, typename T2> inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v) { bool first = true; os << "["; for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if(!first) os << ", "; os << *ii ; first = false; } return os << "]"; }
#else
		#define debug(args...)
#endif

ll n,m;

vi v;
ll t1,t2,pos,val;

int main(){
	ios_base::sync_with_stdio(0);

	cin>>n>>m;
	rep(i,n){
		cin>>t1;
		v.pb(t1);
	}

	rep(i,n)v.pb(v[i]);

	m--;

	t2=n+m;

	val=inf;

	for (int i = t2; i > m ; i--)
	{
		if(v[i]<val){
			val=v[i];
			pos=i;
		}
	}

	pos%=n;
	cout<<pos<<endl;

	if(pos==m){

		v[pos]=n*val;
		rep(i,n)if(i!=pos)v[i]-=val;

	}

	else if(pos<m){

		v[pos]=val*n;

		rep(i,n)if(i!=pos)v[i]-=val;

		repi(i,pos+1,m+1){
			v[i]-=1;
			assert(v[i]>=0);
			v[pos]++;
		}
	}
	else {

		v[pos]=val*n;

		rep(i,n)if(i!=pos)v[i]-=val;

		repi(i,pos+1,n){
			v[i]-=1;
			assert(v[i]>=0);
			v[pos]++;
		}
		rep(i,m+1){
			v[i]-=1;
			assert(v[i]>=0);
			v[pos]++;
		}

	}

	rep(i,n)cout<<v[i]<<" ";

}

//~ 10 3
//~ 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000