#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long MOD = 99990001;
long long a[MAXN << 1];
int n, x;
void printans() {
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    printf("%I64d", a[i]);
  }
  printf("\n");
}
void solved(int cas) {
  scanf("%d %d", &n, &x);
  x--;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    a[i + n] = a[i];
  }
  int mini = x;
  long long minnum = a[x];
  for (int i = x - 1; i >= 0; i--) {
    if (a[i] < minnum) {
      minnum = a[i];
      mini = i;
    }
  }
  for (int i = n - 1; i > x; i--) {
    if (a[i] < minnum) {
      minnum = a[i];
      mini = i;
    }
  }
  if (mini > x) {
    long long temp = 0;
    for (int i = mini + 1; i < n; i++) {
      a[i] -= minnum + 1;
      temp += minnum + 1;
    }
    for (int i = 0; i <= x; i++) {
      a[i] -= minnum + 1;
      temp += minnum + 1;
    }
    for (int i = x + 1; i <= mini; i++) {
      a[i] -= minnum;
      temp += minnum;
    }
    a[mini] = temp;
  } else {
    long long temp = 0;
    for (int i = mini + 1; i <= x; i++) {
      a[i] -= minnum + 1;
      temp += minnum + 1;
    }
    for (int i = mini; i >= 0; i--) {
      a[i] -= minnum;
      temp += minnum;
    }
    for (int i = x + 1; i < n; i++) {
      a[i] -= minnum;
      temp += minnum;
    }
    a[mini] = temp;
  }
  printans();
}
int main() {
  int T = 1;
  for (int i = 1; i <= T; i++) solved(i);
  return 0;
}
