#include <bits/stdc++.h>
using namespace std;
int n, k, x, y, l, r, t;
int m, d, p;
long long a[1000010];
int main() {
  cin >> n >> x;
  for (int(i) = (1); (i) <= (n); ++(i)) {
    cin >> a[i];
  }
  long long ans = 0;
  long long m = 100000000000;
  for (int i = x; i > 0; i--) {
    if (a[i] > 0) {
      a[i]--;
      ans++;
    } else {
      a[i] = ans;
      for (int(i) = (1); (i) <= (n); ++(i)) {
        cout << a[i] << " ";
      }
      exit(0);
    }
  }
  for (int(i) = (1); (i) <= (n); ++(i))
    if (a[i] < m) m = a[i];
  for (int i = n; i > 0; i--) {
    if (a[i] - m > 0) {
      a[i]--;
      ans++;
    } else {
      a[i] = ans + 1LL * n * m;
      for (int(j) = (1); (j) <= (n); ++(j)) {
        if (i != j)
          cout << a[j] - m << " ";
        else
          cout << a[j] << " ";
      }
      exit(0);
    }
  }
  return 0;
}
