#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i;
  while (cin >> n >> i) {
    long long int box[n], min;
    cin >> box[0];
    min = box[0];
    for (long long int i = 1; i < n; i++) {
      cin >> box[i];
      if (box[i] < min) {
        min = box[i];
      }
    }
    long long int count = 0;
    if (min > 2) {
      min -= 2;
    } else {
      min = 0;
    }
    for (long long int i = 0; i < n; i++) {
      box[i] -= min;
    }
    i--;
    while (box[i % n] != 0) {
      box[i % n] -= 1;
      count++;
      i--;
      if (i < 0) {
        i += n;
      }
    }
    box[(i) % n] = count + min * n;
    for (long long int i = 0; i < n; i++) {
      cout << box[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
