Problem: You are given a circular array with n elements. The elements are numbered from some element with values from 1 to n in clockwise order. The i-th cell contains the value ai. The robot Simba is in cell s.

Each moment of time the robot is in some of the n cells (at the begin he is in s). In one turn the robot can write out the number written in current cell or move to the adjacent cell in clockwise or counterclockwise direction. To write out the number from the cell Simba doesn't spend any time, but to move to adjacent cell Simba spends one unit of time.

Simba wants to write the number from each cell one time, so the numbers will be written in a non decreasing order. Find the least number of time units to write out all numbers.

Input

The first line contains two integers n and s (1 ≤ s ≤ n ≤ 2000) — the number of cells in the circular array and the starting position of Simba.

The second line contains n integers ai ( - 109 ≤ ai ≤ 109) — the number written in the i-th cell. The numbers are given for cells in order from 1 to n. Some of numbers ai can be equal.

Output

In the first line print the number t — the least number of time units.

Each of the next n lines should contain the direction of robot movement and the number of cells to move in that direction. After that movement the robot writes out the number from the cell in which it turns out. The direction and the number of cells should be printed in the form of +x in case of clockwise movement and -x in case of counterclockwise movement to x cells (0 ≤ x ≤ n - 1).

Note that the sum of absolute values of x should be equal to t.

Examples

Input

9 1
0 1 2 2 2 1 0 1 1


Output

12
+0
-3
-1
+2
+1
+2
+1
+1
+1


Input

8 1
0 1 0 1 0 1 0 1


Output

13
+0
+2
+2
+2
-1
+2
+2
+2


Input

8 1
1 2 3 4 5 6 7 8


Output

7
+0
+1
+1
+1
+1
+1
+1
+1


Input

8 1
0 0 0 0 0 0 0 0


Output

7
+0
+1
+1
+1
+1
+1
+1
+1

Solution (in CPP):

Solution:
#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]);
  }
}