#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2 * 1e5 + 10, inf = 1e9 * 2;
long long n, x;
vector<long long> a(maxn), pref(maxn, 0), suf(maxn, 0), z(maxn * 4, inf);
void build(long long t, long long tl, long long tr) {
  if (tl == tr) {
    z[t] = a[tl];
    return;
  }
  long long tm = (tl + tr) / 2;
  build(t * 2, tl, tm);
  build(t * 2 + 1, tm + 1, tr);
  z[t] = min(z[t * 2], z[t * 2 + 1]);
}
long long get(long long t, long long tl, long long tr, long long l,
              long long r) {
  if (tl == l && tr == r) return z[t];
  if (l > r) return inf;
  long long tm = (tl + tr) / 2;
  return min(get(t * 2, tl, tm, l, min(r, tm)),
             get(t * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void ans(long long k) {
  long long q = a[k];
  a[k] = q * n;
  if (x > k)
    a[k] += x - k;
  else if (x < k)
    a[k] += n - k + x;
  for (long long i = 1; i <= n; i++)
    if (i != k) a[i] -= q;
  if (x > k) {
    for (long long i = k + 1; i <= x; i++) a[i]--;
  } else if (x < k) {
    for (long long i = k + 1; i <= n; i++) a[i]--;
    for (long long i = 1; i <= x; i++) a[i]--;
  }
  for (long long i = 1; i <= n; i++) cout << a[i] << " ";
  exit(0);
}
int main() {
  cin >> n >> x;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  long long mi = inf;
  for (long long i = 1; i <= n; i++) mi = min(mi, a[i]);
  for (long long i = 1; i <= n; i++)
    if (a[i] == mi) {
      if (x == i)
        ans(i);
      else if (x > i) {
        if (get(1, 1, n, i + 1, x) >= a[i] + 1) {
          ans(i);
        }
      } else {
        if (get(1, 1, n, i + 1, n) >= a[i] + 1 &&
            get(1, 1, n, 1, x) >= a[i] + 1)
          ans(i);
      }
    }
}
