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 MAXN = 2000;
const int INF = int(1E9);
struct node {
  int pos, val, pre[3], ans;
} a[MAXN + 5];
bool operator<(node a, node b) {
  if (a.val == b.val) return a.pos < b.pos;
  return a.val < b.val;
}
int dp[2][MAXN + 5][MAXN + 5], pre[2][MAXN + 5][MAXN + 5][3];
int bgn[MAXN + 5], fa[MAXN + 5], n, s, x;
void Print1(int x);
void Print2(int x, int y, int z) {
  if (y == z) {
    Print1(pre[x][y][z][0]);
    if (a[pre[x][y][z][0]].pos <= a[y].pos) {
      if (a[y].pos - a[pre[x][y][z][0]].pos <
          n - a[y].pos + a[pre[x][y][z][0]].pos)
        printf("+%d\n", a[y].pos - a[pre[x][y][z][0]].pos);
      else
        printf("-%d\n", n - a[y].pos + a[pre[x][y][z][0]].pos);
    } else {
      if (a[pre[x][y][z][0]].pos - a[y].pos <
          n - a[pre[x][y][z][0]].pos + a[y].pos)
        printf("-%d\n", a[pre[x][y][z][0]].pos - a[y].pos);
      else
        printf("+%d\n", n - a[pre[x][y][z][0]].pos + a[y].pos);
    }
  } else {
    Print2(pre[x][y][z][0], pre[x][y][z][1], pre[x][y][z][2]);
    if (x == 0) {
      if (pre[x][y][z][0] == 0) {
        if (a[pre[x][y][z][1]].pos > a[y].pos)
          printf("-%d\n", a[pre[x][y][z][1]].pos - a[y].pos);
        else
          printf("-%d\n", n + a[pre[x][y][z][1]].pos - a[y].pos);
      } else {
        if (a[pre[x][y][z][2]].pos > a[y].pos)
          printf("-%d\n", a[pre[x][y][z][2]].pos - a[y].pos);
        else
          printf("-%d\n", n + a[pre[x][y][z][2]].pos - a[y].pos);
      }
    } else {
      if (pre[x][y][z][0] == 0) {
        if (a[pre[x][y][z][1]].pos < a[z].pos)
          printf("+%d\n", a[z].pos - a[pre[x][y][z][1]].pos);
        else
          printf("+%d\n", n - a[pre[x][y][z][1]].pos + a[z].pos);
      } else {
        if (a[pre[x][y][z][2]].pos < a[z].pos)
          printf("+%d\n", a[z].pos - a[pre[x][y][z][2]].pos);
        else
          printf("+%d\n", n - a[pre[x][y][z][2]].pos + a[z].pos);
      }
    }
  }
}
void Print1(int x) {
  if (x == 0) return;
  Print2(a[x].pre[0], a[x].pre[1], a[x].pre[2]);
}
int main() {
  scanf("%d%d", &n, &s);
  a[0].pos = s, a[0].val = -INF - 5;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    a[i].pos = i, a[i].val = x;
  }
  sort(a, a + n + 1);
  int lst = 0;
  memset(dp, 127, sizeof dp);
  a[n + 1].val = -INF - 5;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i].val != a[lst].val) {
      int p = i - lst;
      for (int j = 0; j < p; j++) {
        dp[0][lst + j][lst + j] = dp[1][lst + j][lst + j] = bgn[a[lst + j].pos];
        pre[0][lst + j][lst + j][0] = pre[1][lst + j][lst + j][0] =
            fa[a[lst + j].pos];
      }
      for (int len = 2; len <= i - lst; len++) {
        for (int j = 0; j < p; j++) {
          int k = (j + len - 1) % p;
          if (dp[1][lst + (j + 1) % p][lst + k] +
                  (a[lst + k].pos + n - a[lst + j].pos) % n <
              dp[0][lst + (j + 1) % p][lst + k] +
                  (a[lst + (j + 1) % p].pos + n - a[lst + j].pos) % n) {
            dp[0][lst + j][lst + k] = dp[1][lst + (j + 1) % p][lst + k] +
                                      (a[lst + k].pos + n - a[lst + j].pos) % n;
            pre[0][lst + j][lst + k][0] = 1;
            pre[0][lst + j][lst + k][1] = lst + (j + 1) % p;
            pre[0][lst + j][lst + k][2] = lst + k;
          } else {
            dp[0][lst + j][lst + k] =
                dp[0][lst + (j + 1) % p][lst + k] +
                (a[lst + (j + 1) % p].pos + n - a[lst + j].pos) % n;
            pre[0][lst + j][lst + k][0] = 0;
            pre[0][lst + j][lst + k][1] = lst + (j + 1) % p;
            pre[0][lst + j][lst + k][2] = lst + k;
          }
          if (dp[1][lst + j][lst + (k + p - 1) % p] +
                  (a[lst + k].pos + n - a[lst + (k + p - 1) % p].pos) % n <
              dp[0][lst + j][lst + (k + p - 1) % p] +
                  (a[lst + k].pos + n - a[lst + j].pos) % n) {
            dp[1][lst + j][lst + k] =
                dp[1][lst + j][lst + (k + p - 1) % p] +
                (a[lst + k].pos + n - a[lst + (k + p - 1) % p].pos) % n;
            pre[1][lst + j][lst + k][0] = 1;
            pre[1][lst + j][lst + k][1] = lst + j;
            pre[1][lst + j][lst + k][2] = lst + (k + p - 1) % p;
          } else {
            dp[1][lst + j][lst + k] = dp[0][lst + j][lst + (k + p - 1) % p] +
                                      (a[lst + k].pos + n - a[lst + j].pos) % n;
            pre[1][lst + j][lst + k][0] = 0;
            pre[1][lst + j][lst + k][1] = lst + j;
            pre[1][lst + j][lst + k][2] = lst + (k + p - 1) % p;
          }
        }
      }
      for (int j = 1; j <= n; j++) bgn[j] = INF;
      for (int j = 0; j < p; j++) {
        if (dp[0][lst + j][lst + (j + p - 1) % p] <
            dp[1][lst + (j + 1) % p][lst + j]) {
          a[lst + j].ans = dp[0][lst + j][lst + (j + p - 1) % p];
          a[lst + j].pre[0] = 0;
          a[lst + j].pre[1] = lst + j;
          a[lst + j].pre[2] = lst + (j + p - 1) % p;
        } else {
          a[lst + j].ans = dp[1][lst + (j + 1) % p][lst + j];
          a[lst + j].pre[0] = 1;
          a[lst + j].pre[1] = lst + (j + 1) % p;
          a[lst + j].pre[2] = lst + j;
        }
        for (int k = 1; k <= n; k++)
          if (a[lst + j].ans +
                  min(n - abs(a[lst + j].pos - k), abs(a[lst + j].pos - k)) <
              bgn[k]) {
            bgn[k] = a[lst + j].ans +
                     min(n - abs(a[lst + j].pos - k), abs(a[lst + j].pos - k));
            fa[k] = lst + j;
          }
      }
      if (i == n + 1) {
        int minx = lst;
        for (int j = 0; j < p; j++) {
          if (a[lst + j].ans < a[minx].ans) minx = lst + j;
        }
        printf("%d\n", a[minx].ans);
        Print1(minx);
      }
      lst = i;
    }
  }
}