#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int n, x;
long long a[N];
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
  x--;
  for (int i = x; i >= 0; i--) {
    if (a[i] == 0) {
      a[i] = x - i;
      for (int j = 0; j < n; j++) printf("%I64d ", a[j]);
      return 0;
    }
    a[i]--;
  }
  int pos = n - 1;
  for (int i = n - 2; i >= 0; i--)
    if (a[i] < a[pos]) pos = i;
  for (int i = 0; i < n; i++) {
    if (i < pos)
      a[i] -= a[pos];
    else if (i > pos)
      a[i] -= a[pos] + 1;
  }
  a[pos] = a[pos] * n + (n - 1 - pos) + (x + 1);
  for (int i = 0; i < n; i++) printf("%I64d ", a[i]);
  return 0;
}
