#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int N, X;
long long int cnt;
long long int ar[MAXN];
void esc() {
  for (int i = 1; i < N; i++) cout << ar[i] << " ";
  cout << ar[N] << endl;
  exit(0);
}
int main() {
  cin >> N >> X;
  for (int i = 1; i <= N; i++) scanf(" %d", ar + i);
  for (int i = X; i; i--)
    if (!ar[i]) {
      ar[i] = cnt;
      esc();
    } else
      ar[i]--, cnt++;
  int mn = 1;
  for (int i = 2; i <= N; i++)
    if (ar[i] <= ar[mn]) mn = i;
  for (int i = 1, tmp = ar[mn]; i <= N; i++) ar[i] -= tmp, cnt += tmp;
  for (int i = mn + 1; i <= N; i++) ar[i]--, cnt++;
  ar[mn] = cnt;
  esc();
  return 0;
}
