#include <bits/stdc++.h>
using namespace std;
const int N = 2500;
struct node {
  int a, id;
  bool operator<(node T) const {
    if (a == T.a) return id < T.id;
    return a < T.a;
  }
} a[N];
int n, start[N], k = 0, pos;
int val[N];
int finish[N];
int last[N];
pair<int, int> inner[N];
vector<int> block[N];
inline int GetDist(int i, int j) { return min(abs(i - j), n - abs(i - j)); }
inline int getLeft(int i, int j) {
  if (i >= j) return i - j;
  return i + n - j;
}
inline int getRight(int i, int j) {
  if (i <= j) return j - i;
  return n + j - i;
}
inline void recalc(int id) {
  if ((int)block[id].size() == 1) {
    finish[block[id][0]] = start[block[id][0]];
    inner[block[id][0]] = make_pair(block[id][0], 0);
    return;
  }
  for (int i = 0; i < (int)block[id].size(); ++i) {
    int nxt = i + 1;
    int prv = i - 1;
    if (nxt >= (int)block[id].size()) nxt = 0;
    if (prv < 0) prv = (int)block[id].size() - 1;
    nxt = block[id][nxt];
    prv = block[id][prv];
    for (int j = 0; j < (int)block[id].size(); ++j) {
      if (finish[block[id][j]] > start[block[id][i]] +
                                     getRight(block[id][i], prv) +
                                     GetDist(prv, block[id][j])) {
        finish[block[id][j]] = start[block[id][i]] +
                               getRight(block[id][i], prv) +
                               GetDist(prv, block[id][j]);
        inner[block[id][j]] = make_pair(block[id][i], 0);
      }
      if (finish[block[id][j]] > start[block[id][i]] +
                                     getLeft(block[id][i], nxt) +
                                     GetDist(nxt, block[id][j])) {
        finish[block[id][j]] = start[block[id][i]] +
                               getLeft(block[id][i], nxt) +
                               GetDist(nxt, block[id][j]);
        inner[block[id][j]] = make_pair(block[id][i], 1);
      }
    }
  }
}
inline void Find(int id) {
  for (int i = 0; i < (int)block[id].size(); ++i) {
    for (int j = 0; j < (int)block[id + 1].size(); ++j) {
      if (start[block[id + 1][j]] >
          finish[block[id][i]] + GetDist(block[id][i], block[id + 1][j])) {
        start[block[id + 1][j]] =
            finish[block[id][i]] + GetDist(block[id][i], block[id + 1][j]);
        last[block[id + 1][j]] = block[id][i];
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &pos);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].a);
    a[i].id = i;
    val[i] = a[i].a;
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n;) {
    int j = i;
    while (j + 1 <= n && a[i].a == a[j + 1].a) ++j;
    ++k;
    for (; i <= j; ++i) {
      block[k].push_back(a[i].id);
    }
  }
  for (int i = 1; i <= n; ++i) {
    start[i] = 1000000000;
    finish[i] = 1000000000;
  }
  for (int i = 0; i < (int)block[1].size(); ++i) {
    start[block[1][i]] = GetDist(pos, block[1][i]);
    last[block[1][i]] = pos;
  }
  for (int i = 1; i <= k; ++i) {
    recalc(i);
    if (i < k) {
      Find(i);
    }
  }
  int ans = 1000000000, v = 0;
  for (int i = 0; i < (int)block[k].size(); ++i) {
    if (ans > finish[block[k][i]]) {
      ans = finish[block[k][i]];
      v = block[k][i];
    }
  }
  printf("%d\n", ans);
  vector<int> all;
  for (int now = k; now > 0; --now) {
    int nxt = inner[v].first;
    int dir = inner[v].second;
    int who = val[v];
    for (int cnt = 0;;) {
      if (v == nxt && cnt >= (int)block[now].size()) break;
      if (who == val[v]) {
        all.push_back(v);
        cnt++;
        val[v] = 1000000000;
      }
      if (!dir)
        --v;
      else
        ++v;
      if (v <= 0) v = n;
      if (v > n) v = 1;
    }
    v = last[v];
  }
  for (int i = (int)all.size() - 1; i >= 0; --i) {
    if (getRight(pos, all[i]) <= getLeft(pos, all[i]))
      printf("+");
    else
      printf("-");
    printf("%d\n", GetDist(pos, all[i]));
    pos = all[i];
  }
  return 0;
}
