#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 100010;
long long arr[maxn];
int rmq[25][maxn], lg[maxn], n;
void rmq_init() {
  int i, j;
  for (i = 0; i < n; i++) rmq[0][i] = arr[i];
  for (i = 1; i <= lg[n]; i++)
    for (j = 0; j + (1 << i) - 1 < n; j++)
      rmq[i][j] = min(rmq[i - 1][j], rmq[i - 1][j + (1 << (i - 1))]);
}
int rmq_min(int l, int r) {
  int tmp = lg[r - l + 1];
  return min(rmq[tmp][l], rmq[tmp][r - (1 << tmp) + 1]);
}
void prermq() {
  int i;
  lg[0] = -1;
  for (i = 1; i < maxn; i++) lg[i] = lg[i >> 1] + 1;
}
int main() {
  int i, x, p, ma, mb;
  prermq();
  while (~scanf("%d%d", &n, &x)) {
    x--;
    for (i = 0; i < n; i++) scanf("%I64d", &arr[i]);
    rmq_init();
    for (i = 0; i < n; i++) {
      ma = mb = INF;
      if (i != 0) ma = rmq_min(0, i - 1);
      if (i != n - 1) mb = rmq_min(i + 1, n - 1);
      if (min(ma, mb) - arr[i] >= 0) {
        if (x > i) {
          if (rmq_min(i + 1, x) - arr[i] >= 1) break;
        } else if (x == i)
          break;
        else {
          mb = INF;
          if (i != n - 1) mb = rmq_min(i + 1, n - 1);
          ma = rmq_min(0, x);
          if (min(ma, mb) - arr[i] >= 1) break;
        }
      }
    }
    p = i;
    for (i = 0; i < n; i++)
      if (i != p) arr[i] -= arr[p];
    if (x > p) {
      for (i = p + 1; i <= x; i++) arr[i]--;
      arr[p] = arr[p] * n + x - p;
    } else if (x < p) {
      for (i = p + 1; i < n; i++) arr[i]--;
      for (i = 0; i <= x; i++) arr[i]--;
      arr[p] = arr[p] * n + x + n - p;
    } else
      arr[p] = n * arr[p];
    printf("%I64d", arr[0]);
    for (i = 1; i < n; i++) printf(" %I64d", arr[i]);
    printf("\n");
  }
  return 0;
}
