#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n, in, a[200005], l = -1, r = -1;
  cin >> n >> in;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= in; i++) {
    if (i == 1)
      l = a[i];
    else
      l = min(l, a[i]);
  }
  for (int i = in + 1; i <= n; i++) {
    if (i == in + 1)
      r = a[i];
    else
      r = min(r, a[i]);
  }
  if (r == -1) {
    if (l == 0) {
      long long int ans = 0;
      for (int i = n; i >= 1; i--) {
        if (a[i] == 0ll) {
          a[i] = ans;
          break;
        } else {
          ans++;
          a[i]--;
        }
      }
      for (int i = 1; i <= n; i++) cout << a[i] << " ";
    } else {
      for (int i = 1; i <= n; i++) a[i] -= l;
      long long int ans = l * n;
      for (int i = n; i >= 1; i--) {
        if (a[i] == 0ll) {
          a[i] = ans;
          break;
        } else {
          ans++;
          a[i]--;
        }
      }
      for (int i = 1; i <= n; i++) cout << a[i] << " ";
    }
  } else {
    if (l > 0 and r > 0) {
      long long int ans = 0;
      if (l > r) {
        l = r + 1;
        for (int i = 1; i <= in; i++) {
          a[i] -= l;
          ans += l;
        }
        for (int i = in + 1; i <= n; i++) {
          a[i] -= r;
          ans += r;
        }
        for (int i = n; i >= 1; i--) {
          if (a[i] == 0ll) {
            a[i] = ans;
            break;
          } else {
            ans++;
            a[i]--;
          }
        }
      } else {
        long long int mn = min(l, r);
        for (int i = 1; i <= n; i++) {
          a[i] -= mn;
          ans += mn;
        }
        for (int i = in; i >= 1; i--) {
          if (a[i] == 0ll) {
            a[i] = ans;
            break;
          } else {
            ans++;
            a[i]--;
          }
        }
      }
      for (int i = 1; i <= n; i++) cout << a[i] << " ";
    } else if (l == 0) {
      long long int ans = 0;
      for (int i = in; i >= 1; i--) {
        if (a[i] == 0ll) {
          a[i] = ans;
          break;
        } else {
          ans++;
          a[i]--;
        }
      }
      for (int i = 1; i <= n; i++) cout << a[i] << " ";
    } else {
      long long int ans = 0;
      for (int i = in; i >= 1; i--) {
        a[i]--;
        ans++;
      }
      for (int i = n; i >= 1; i--) {
        if (a[i] == 0ll) {
          a[i] = ans;
          break;
        } else {
          ans++;
          a[i]--;
        }
      }
      for (int i = 1; i <= n; i++) cout << a[i] << " ";
    }
  }
  return 0;
}
