#include <bits/stdc++.h>
using std::cin;
using std::cout;
int dist(int from, int to, int count) {
  if (from <= to) {
    return to - from;
  } else {
    return dist(from, count - 1, count) + dist(0, to, count) + 1;
  }
}
void output(const std::vector<int64_t>& boxes);
std::vector<int64_t> recover(const std::vector<int64_t>& boxes, int lastBox) {
  std::vector<int64_t> result(boxes.size());
  int minValue = *std::min_element(boxes.begin(), boxes.end());
  int index = -1;
  int minDist = -1;
  for (size_t i = 0; i < boxes.size(); ++i) {
    if (boxes[i] == minValue) {
      if (index == -1 || minDist > dist(i, lastBox, boxes.size())) {
        index = i;
        minDist = dist(i, lastBox, boxes.size());
      }
    }
  }
  int64_t wasBalls =
      boxes[index] * boxes.size() + dist(index, lastBox, boxes.size());
  for (size_t i = 0; i < boxes.size(); ++i) {
    if (i == index) {
      result[i] = wasBalls;
    } else {
      int dst = dist(index, i, boxes.size()) - 1;
      if (wasBalls >= dst) {
        int64_t rem = wasBalls - dst;
        int64_t add = rem / boxes.size();
        if (rem % boxes.size() != 0) {
          ++add;
        }
        result[i] = boxes[i] - add;
        assert(result[i] >= 0);
      } else {
        result[i] = boxes[i];
      }
    }
  }
  return result;
}
void output(const std::vector<int64_t>& boxes) {
  for (size_t i = 0; i < boxes.size(); ++i) {
    cout << boxes[i] << ' ';
  }
  cout << '\n';
}
void input(std::vector<int64_t>* boxes, int* lastBox) {
  int count;
  cin >> count >> *lastBox;
  --(*lastBox);
  boxes->resize(count);
  for (int i = 0; i < count; ++i) {
    cin >> (*boxes)[i];
  }
}
void stressTest() {
  int N = 10;
  for (int tc = 0; tc < 1000; ++tc) {
    std::vector<int64_t> a(N);
    for (size_t i = 0; i < a.size(); ++i) {
      if (rand() % 4 == 0) {
        a[i] = 0;
      } else {
        a[i] = rand() % 1000;
      }
    }
    int start = -1;
    while (true) {
      start = rand() % N;
      if (a[start] == 0) {
        continue;
      }
      break;
    }
    int cnt = a[start];
    int realCnt = cnt;
    a[start] = 0;
    int i = (start + 1) % N;
    for (; cnt > 0; cnt--, i = (i + 1) % N) {
      ++a[i];
    }
    int end = (i + N - 1) % N;
    std::vector<int64_t> b = recover(a, end);
    assert(b[start] == realCnt);
    b[start] = 0;
    i = (start + 1) % N;
    cnt = realCnt;
    for (; cnt > 0; cnt--, i = (i + 1) % N) {
      ++b[i];
    }
    if (a != b) {
      cout << end + 1 << '\n';
      output(a);
      output(b);
      exit(0);
    }
    assert(a == b);
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::vector<int64_t> boxes;
  int lastBox;
  input(&boxes, &lastBox);
  output(recover(boxes, lastBox));
  return 0;
}
