#include <bits/stdc++.h>
using namespace std;
const int N = 2005, INF = 0x3f3f3f3f;
int n, m, a[N], b[2][N], id;
int f[N], d[N][N], ans = INF;
int xy[N][N], fa[N][2];
int now, rr[N][2];
struct node {
  int x, id;
} p[N];
bool cmp(node a, node b) { return a.x != b.x ? a.x < b.x : a.id < b.id; }
void getd() {
  for (int i = 1; i <= n; i++) {
    if (i - 1 < n - i + 1) {
      d[0][i] = d[i][0] = i - 1;
      xy[0][i] = 1, xy[i][0] = -1;
    } else {
      d[0][i] = d[i][0] = n - i + 1;
      xy[0][i] = -1, xy[i][0] = 1;
    }
    d[i][i] = 0, xy[i][i] = 1;
    for (int j = i + 1; j <= n; j++) {
      if (j - i < n - (j - i)) {
        d[i][j] = d[j][i] = j - i;
        xy[i][j] = 1, xy[j][i] = -1;
      } else {
        d[i][j] = d[j][i] = n - (j - i);
        xy[i][j] = -1, xy[j][i] = 1;
      }
    }
  }
}
void getf() {
  id = 0, b[0][0] = 1, b[0][1] = 0;
  for (int i = 1; i <= n; i++) {
    id ^= 1;
    int t = i;
    b[id][b[id][0] = 1] = p[i].id;
    while (p[t + 1].x == p[t].x && t < n) {
      b[id][++b[id][0]] = p[++t].id;
    }
    for (int j = 1; j <= b[id ^ 1][0]; j++) {
      int u = b[id ^ 1][j], v, l;
      if (b[id][0] == 1) {
        v = p[t].id;
        if (f[v] > f[u] + d[u][v]) {
          f[v] = f[u] + d[u][v];
          fa[v][0] = u, fa[v][1] = 0;
        }
      } else {
        for (int k = 2; k <= b[id][0]; k++) {
          v = b[id][k], l = b[id][k - 1];
          if (f[v] > f[u] + d[u][l] + n - (v - l)) {
            f[v] = f[u] + d[u][l] + n - (v - l);
            fa[v][0] = u, fa[v][1] = -1;
          }
          if (f[l] > f[u] + d[u][v] + n - (v - l)) {
            f[l] = f[u] + d[u][v] + n - (v - l);
            fa[l][0] = u, fa[l][1] = 1;
          }
        }
        v = b[id][1], l = b[id][b[id][0]];
        if (f[v] > f[u] + d[u][l] + l - v) {
          f[v] = f[u] + d[u][l] + l - v;
          fa[v][0] = u, fa[v][1] = -1;
        }
        if (f[l] > f[u] + d[u][v] + l - v) {
          f[l] = f[u] + d[u][v] + l - v;
          fa[l][0] = u, fa[l][1] = 1;
        }
      }
    }
    i = t;
  }
}
int main() {
  memset(f, 0x3f, sizeof(f)), f[0] = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[(i - m + n) % n + 1]);
  for (int i = 1; i <= n; i++) p[i].x = a[i], p[i].id = i;
  sort(p + 1, p + n + 1, cmp), m = 0;
  getd(), getf();
  for (int i = 1; i <= b[id][0]; i++) {
    if (ans > f[b[id][i]]) {
      ans = f[b[id][i]];
      now = b[id][i];
    }
  }
  printf("%d\n", ans);
  for (int i = n; i >= 1; i--) {
    id ^= 1;
    int t = i, k, u, v, l;
    u = fa[now][0], b[id][0] = 0;
    while (p[t - 1].x == p[t].x && t > 1) --t;
    for (int j = t; j <= i; j++) {
      b[id][++b[id][0]] = p[j].id;
    }
    if (b[id][0] == 1) {
      rr[++m][0] = d[now][u];
      rr[m][1] = xy[u][now];
    } else {
      for (int j = 1; j <= b[id][0]; j++) {
        if (b[id][j] == now) v = j;
      }
      if (fa[now][1] == 1) {
        for (int j = v;; j--) {
          if (j == 0) j = b[id][0];
          if (v == b[id][0] && j == 1 || j == v + 1) {
            rr[++m][0] = d[b[id][j]][u];
            rr[m][1] = xy[u][b[id][j]];
            break;
          }
          if (j == 1) {
            rr[++m][0] = b[id][j] - b[id][b[id][0]] + n;
            rr[m][1] = 1;
          } else {
            rr[++m][0] = b[id][j] - b[id][j - 1];
            rr[m][1] = 1;
          }
        }
      } else {
        for (int j = v;; j++) {
          if (j == b[id][0] + 1) j = 1;
          if (v == 1 && j == b[id][0] || j == v - 1) {
            rr[++m][0] = d[b[id][j]][u];
            rr[m][1] = xy[u][b[id][j]];
            break;
          }
          if (j == b[id][0]) {
            rr[++m][0] = b[id][1] - b[id][j] + n;
            rr[m][1] = -1;
          } else {
            rr[++m][0] = b[id][j + 1] - b[id][j];
            rr[m][1] = -1;
          }
        }
      }
    }
    now = fa[now][0], i = t;
  }
  for (int i = m; i >= 1; i--) {
    if (rr[i][1] == 1)
      printf("+");
    else
      printf("-");
    printf("%d\n", rr[i][0]);
  }
}
