#include <bits/stdc++.h>
using namespace std;
int N, S;
int A[2020];
vector<int> V;
vector<int> pos[2020];
int dist[2020][2020];
int from[2020][2020];
int rev[2020];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> S;
  S--;
  for (i = 0; i < (N); i++) cin >> A[i], V.push_back(A[i]);
  V.push_back(-1 << 30);
  sort((V.begin()), (V.end()));
  V.erase(unique((V.begin()), (V.end())), V.end());
  for (i = 0; i < (N); i++) {
    A[i] = lower_bound((V.begin()), (V.end()), A[i]) - V.begin();
    pos[A[i]].push_back(i);
    pos[A[i]].push_back(N + i);
    pos[A[i]].push_back(2 * N + i);
    pos[A[i]].push_back(3 * N + i);
    pos[A[i]].push_back(4 * N + i);
  }
  pos[0].push_back(S);
  pos[0].push_back(1 * N + S);
  pos[0].push_back(2 * N + S);
  pos[0].push_back(3 * N + S);
  pos[0].push_back(4 * N + S);
  for (i = 0; i < (N + 1); i++) {
    sort((pos[i].begin()), (pos[i].end()));
    if (i)
      for (j = 0; j < (pos[i].size()); j++) rev[pos[i][j]] = j;
  }
  for (i = 0; i < (N + 1); i++)
    for (j = 0; j < (N + 1); j++) dist[i][j] = 1 << 30;
  dist[0][S] = 0;
  for (i = 0; i < (V.size() - 1); i++) {
    for (x = 0; x < (pos[i].size() / 5); x++) {
      if (pos[i + 1].size() == 5) {
        int st = pos[i][x];
        int ed = pos[i + 1][0];
        int tot = dist[i][st] + min(abs(st - ed), N - abs(st - ed));
        if (tot < dist[i + 1][ed]) {
          dist[i + 1][ed] = tot;
          from[i + 1][ed] = st;
        }
      } else {
        for (y = 0; y < (pos[i + 1].size() / 5); y++) {
          int st = pos[i][x + 2 * pos[i].size() / 5];
          int ed = pos[i + 1][y + 2 * pos[i + 1].size() / 5];
          int pre = pos[i + 1][y + 2 * pos[i + 1].size() / 5 - 1];
          int nex = pos[i + 1][y + 2 * pos[i + 1].size() / 5 + 1];
          if (ed < st) ed += N, pre += N, nex += N;
          int tot = N - (ed - st);
          if (pre > st) tot += (pre - st) * 2;
          if (nex >= st + N) {
            tot = min(tot, ed - st);
          } else {
            tot = min(tot, 2 * (N - (nex - st)) + (ed - st));
          }
          ed = pos[i + 1][y];
          tot += dist[i][pos[i][x]];
          if (tot < dist[i + 1][ed]) {
            dist[i + 1][ed] = tot;
            from[i + 1][ed] = pos[i][x];
          }
        }
      }
    }
  }
  int st = min_element(dist[V.size() - 1], dist[V.size() - 1] + N) -
           dist[V.size() - 1];
  (void)printf("%d\n", dist[V.size() - 1][st]);
  vector<int> R;
  for (i = V.size() - 1; i >= 1; i--) {
    R.push_back(st);
    st = from[i][st];
  }
  R.push_back(S);
  reverse((R.begin()), (R.end()));
  for (i = 0; i < (R.size() - 1); i++) {
    int st = 2 * N + R[i];
    int y = rev[R[i + 1]];
    int ed = pos[i + 1][y + 2 * pos[i + 1].size() / 5];
    int pre = pos[i + 1][y + 2 * pos[i + 1].size() / 5 - 1];
    int nex = pos[i + 1][y + 2 * pos[i + 1].size() / 5 + 1];
    if (st > ed) st -= N;
    int tot1 = N - (ed - st);
    if (pre > st) tot1 += (pre - st) * 2;
    int tot2 = ed - st;
    if (nex < st + N) tot2 += 2 * (N - (nex - st));
    vector<int> pat;
    pat.push_back(st);
    if (tot1 < tot2) {
      for (auto& r : pos[i + 1])
        if (r >= st && r <= pre) pat.push_back(r);
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
      for (auto& r : pos[i + 1])
        if (r >= ed && r < st + N) pat.push_back(r - N);
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
    } else {
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
      for (auto& r : pos[i + 1])
        if (r < st + N && r >= nex) pat.push_back(r - N);
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
      for (auto& r : pos[i + 1])
        if (r >= st && r <= ed) pat.push_back(r);
    }
    for (j = 0; j < (pat.size() - 1); j++) {
      x = pat[j + 1] - pat[j];
      if (x >= 0)
        (void)printf("+%d\n", x);
      else
        (void)printf("%d\n", x);
    }
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
