#include <bits/stdc++.h>
using namespace std;
long double PI = 3.14159265358979323846;
int modo = 1e9 + 7;
const long long inf = 1e13;
const long long ms = (1e5) + 5;
long long ar[ms] = {0};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  long long n;
  long long k;
  cin >> n >> k;
  long long i;
  long long mx = INT_MAX;
  long long ind = -1;
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
    if (mx > ar[i]) {
      mx = ar[i];
      ind = i;
    }
  }
  long long pp = mx * n;
  for (i = 1; i <= n; i++) ar[i] -= mx;
  ind = 0;
  for (i = k; i >= 1; i--) {
    if (ar[i]) {
      ar[i]--;
      pp++;
    } else {
      ind = i;
      break;
    }
  }
  if (!ind) {
    for (i = n; i >= k; i--) {
      if (ar[i]) {
        ar[i]--;
        pp++;
      } else {
        ind = i;
        break;
      }
    }
  }
  ar[ind] = pp;
  for (i = 1; i <= n; i++) cout << ar[i] << " ";
  return 0;
}
