#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 100000 + 10;
pair<long long, long long> a[Maxn];
bool mark[Maxn];
vector<long long> v;
long long b[Maxn];
long long n, x;
long long F(long long a) {
  if (a == n)
    return 1;
  else
    return a + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> x;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
    b[i] = a[i].first;
  }
  sort(a + 1, a + n + 1);
  long long tmp;
  for (long long i = 1; i <= n; i++) {
    tmp = i;
    if (a[i + 1].first != a[i].first) {
      i = n + 1;
    }
  }
  for (long long i = 1; i <= tmp; i++) {
    v.push_back(a[i].second);
  }
  long long k = a[1].first;
  bool reza = false;
  sort(v.begin(), v.end());
  for (long long i = 0; i < v.size(); i++) mark[v[i]] = true;
  for (long long i = x; i > 0; i--) {
    if (b[i] == k && reza == false) {
      tmp = i;
      reza = true;
    }
  }
  if (reza == false) {
    for (long long i = n; i > x; i--) {
      if (b[i] == k && reza == false) {
        reza = true;
        tmp = i;
      }
    }
  }
  long long ss = 0;
  long long u = b[tmp];
  if (tmp == x) {
    for (long long i = 1; i <= n; i++) b[i] -= u - 1;
    for (long long i = F(tmp); i != x; i = F(i)) {
      ss++;
      b[i]--;
    }
    b[tmp] = u * n;
    for (long long i = 1; i <= n; i++) cout << b[i] << " ";
    return 0;
  }
  for (long long i = 1; i <= n; i++) b[i] -= u;
  for (long long i = F(tmp); i != x; i = F(i)) {
    ss++;
    b[i]--;
  }
  b[x]--;
  b[tmp] = u * n + ss + 1;
  for (long long i = 1; i <= n; i++) cout << b[i] << " ";
}
