#include <bits/stdc++.h>
using namespace std;
void PLAY() {
  cout << fixed << setprecision(10);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int max(int a, int b) {
  if (a > b) return a;
  return b;
}
int min(int a, int b) {
  if (a < b) return a;
  return b;
}
long long fx4[] = {-1, 1, 0, 0};
long long fy4[] = {0, 0, -1, 1};
long long fx8[] = {-1, -1, -1, 0, 1, 1, 1, 0};
long long fy8[] = {-1, 0, 1, 1, 1, 0, -1, -1};
const double PI = 3.141592653589793;
const long long N = 2e5 + 5;
const long long mod = 1000000007;
long long n, idx, idxm = -1;
long long arr[N];
long long ans[N];
int32_t main() {
  PLAY();
  cin >> n >> idx;
  idx--;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long min = 99999999999999;
  for (long long i = 0; i < n; i++) {
    if (arr[i] <= min) {
      min = arr[i];
      idxm = i;
    }
  }
  for (long long i = 0; i < n; i++) {
    ans[i] = arr[i] - min;
  }
  while (1) {
    if (ans[idx] == 0) break;
    ans[idx] -= 1;
    idx = (n + idx - 1) % n;
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += arr[i] - ans[i];
  }
  ans[idx] = sum;
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
}
