#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e3 + 5;
const int inf = 0x3f3f3f3f;
int n, s;
int a[mxn];
vector<int> vec;
vector<int> pos[mxn];
vector<vector<int> > dp[mxn][2];
vector<vector<pair<int, int> > > pr[mxn][2];
int dis(int x, int y) {
  x %= n, y %= n;
  return min(abs(x - y), n - abs(x - y));
}
int at(int i, int p) { return pos[i][p % pos[i].size()]; }
void write(int x) {
  if (x >= 0)
    printf("+%d\n", x);
  else
    printf("%d\n", x);
}
void go(int x, int y) {
  x %= n, y %= n;
  if (abs(x - y) < n - abs(x - y))
    write(y - x);
  else
    write(x < y ? -(x + n - y) : n - x + y);
}
void prt(int i, int c, int l, int r) {
  if (!i) return;
  if (l == r) {
    prt(i - 1, pr[i][c][l][r].first, pr[i][c][l][r].second,
        pr[i][c][l][r].second + pos[i - 1].size() - 1);
    int p = at(i - 1, pr[i][c][l][r].first == 0
                          ? pr[i][c][l][r].second
                          : pr[i][c][l][r].second + pos[i - 1].size() - 1);
    int q = at(i, c == 0 ? l : r);
    go(p, q);
  } else {
    prt(i, pr[i][c][l][r].first, c == 0 ? l + 1 : l, c == 1 ? r - 1 : r);
    int p = at(i, pr[i][c][l][r].first == 0 ? (c == 0 ? l + 1 : l)
                                            : (c == 1 ? r - 1 : r));
    int q = at(i, c == 0 ? l : r);
    go(p, q);
  }
}
int main() {
  scanf("%d %d", &n, &s);
  --s;
  for (int i = 0; i < (int)(n); ++i) scanf("%d", &a[i]);
  for (int i = 0; i < (int)(n); ++i) vec.push_back(a[i]);
  vec.push_back(-inf);
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0; i < (int)(n); ++i)
    pos[lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin()].push_back(i);
  pos[0].push_back(s);
  for (int i = 0; i < (int)(vec.size()); ++i) {
    for (int c = 0; c < (int)(2); ++c) {
      dp[i][c].resize(pos[i].size() << 1);
      pr[i][c].resize(pos[i].size() << 1);
      for (int j = 0; j < (int)(pos[i].size() << 1); ++j)
        dp[i][c][j].resize(pos[i].size() << 1, inf);
      for (int j = 0; j < (int)(pos[i].size() << 1); ++j)
        pr[i][c][j].resize(pos[i].size() << 1, make_pair(-1, -1));
    }
  }
  for (int l = 0; l < (pos[0].size() << 1); ++l)
    for (int r = l; r < (pos[0].size() << 1) && r - l + 1 <= pos[0].size(); ++r)
      for (int c = 0; c < (int)(2); ++c) dp[0][c][l][r] = 0;
  for (int i = 0; i < (int)(vec.size()); ++i)
    if (i) {
      vector<int> v;
      for (int j = 0; j < (int)(pos[i].size()); ++j) v.push_back(pos[i][j]);
      for (int j = 0; j < (int)(pos[i].size()); ++j) v.push_back(pos[i][j] + n);
      for (int j = 0; j < (int)(pos[i - 1].size()); ++j)
        for (int c = 0; c < (int)(2); ++c) {
          int p = at(i - 1, c == 0 ? j : j + pos[i - 1].size() - 1);
          int pre = lower_bound(v.begin(), v.end(), p) - v.begin();
          --pre;
          int suf = pre + 1;
          if (pre >= 0) {
            if (dp[i][0][pre][pre] >
                dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                    dis(p, at(i, pre))) {
              dp[i][0][pre][pre] = dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                                   dis(p, at(i, pre));
              pr[i][0][pre][pre] = make_pair(c, j);
            }
          }
          if (suf < v.size()) {
            if (dp[i][0][suf][suf] >
                dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                    dis(p, at(i, suf))) {
              dp[i][0][suf][suf] = dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                                   dis(p, at(i, suf));
              pr[i][0][suf][suf] = make_pair(c, j);
            }
          }
        }
      for (int j = 0; j < (int)(pos[i].size()); ++j) {
        if (dp[i][0][j + pos[i].size()][j + pos[i].size()] > dp[i][0][j][j]) {
          dp[i][0][j + pos[i].size()][j + pos[i].size()] = dp[i][0][j][j];
          pr[i][0][j + pos[i].size()][j + pos[i].size()] = pr[i][0][j][j];
        }
      }
      for (int j = 0; j < (int)(pos[i].size()); ++j) {
        if (dp[i][0][j][j] > dp[i][0][j + pos[i].size()][j + pos[i].size()]) {
          dp[i][0][j][j] = dp[i][0][j + pos[i].size()][j + pos[i].size()];
          pr[i][0][j][j] = pr[i][0][j + pos[i].size()][j + pos[i].size()];
        }
      }
      for (int l = (int)(pos[i].size() << 1) - 1; ~l; --l) {
        for (int r = l + 1;
             r < (pos[i].size() << 1) && r - l + 1 <= pos[i].size(); ++r) {
          for (int c = 0; c < (int)(2); ++c) {
            int nl = c == 0 ? l + 1 : l;
            int nr = c == 1 ? r - 1 : r;
            for (int nc = 0; nc < (int)(2); ++nc) {
              if (dp[i][c][l][r] >
                  dp[i][nc][nl][nr] +
                      dis(at(i, nc == 0 ? nl : nr), at(i, c == 0 ? l : r))) {
                dp[i][c][l][r] =
                    dp[i][nc][nl][nr] +
                    dis(at(i, nc == 0 ? nl : nr), at(i, c == 0 ? l : r));
                pr[i][c][l][r] = make_pair(nc, -1);
              }
            }
          }
        }
      }
    }
  int ans = inf;
  pair<int, int> ansi = make_pair(-1, -1);
  for (int i = 0; i < (int)(pos[vec.size() - 1].size()); ++i)
    for (int c = 0; c < (int)(2); ++c) {
      if (ans > dp[vec.size() - 1][c][i][i + pos[vec.size() - 1].size() - 1]) {
        ans = dp[vec.size() - 1][c][i][i + pos[vec.size() - 1].size() - 1];
        ansi = make_pair(i, c);
      }
    }
  printf("%d\n", ans);
  prt(vec.size() - 1, ansi.second, ansi.first,
      ansi.first + pos[vec.size() - 1].size() - 1);
  return 0;
}
