#include <bits/stdc++.h>
using namespace std;
int const siz = 1e9, bound = 5e5, mod = siz + 7;
long long const oo = 1e18;
long long aa[bound];
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  pair<long long, long long> mn = make_pair((siz), (-1));
  scanf("%d", &n), scanf("%d", &m);
  for (int(i) = 0; (i) < (n); (i)++) {
    scanf("%lld", &aa[i]);
    if (aa[i] < mn.first) mn = make_pair((aa[i]), (i));
  }
  long long bll = n * mn.first;
  int i = m - 1;
  while (1) {
    aa[i] -= mn.first;
    i--;
    if (i < 0) i = n - 1;
    if (i == m - 1) break;
  }
  while (aa[i] != 0) {
    bll++;
    aa[i]--;
    i--;
    if (i < 0) i = n - 1;
  }
  aa[i] = bll;
  for (int(i) = 0; (i) < (n); (i)++) printf("%lld ", aa[i]);
  puts("");
  return 0;
}
