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;
int n, s, la = INT_MIN, ta, tb, tc;
pair<int, int> x[2005];
vector<vector<int> > y, z;
vector<int> yy;
int sf[2005], sv[2005], tf[2005], tv[2005], tt[2005], aa[2005], bb[2005],
    cc[2005];
int f1(int a, int b, int c, int d) {
  if (((1 << (c)) * (d)) == a && ((1 << (c)) * (d + 1)) == b) return z[c][d];
  c--;
  d = d * 2 + 1;
  if (b <= ((1 << (c)) * (d))) return f1(a, b, c, d - 1);
  if (a >= ((1 << (c)) * (d))) return f1(a, b, c, d);
  int tta = f1(a, ((1 << (c)) * (d)), c, d - 1),
      ttb = f1(((1 << (c)) * (d)), b, c, d);
  if (yy[tta] <= yy[ttb]) return tta;
  return ttb;
}
void f2(int a, int b) {
  if (a == b)
    printf("+0\n");
  else if (a > b) {
    if (a - b < n - (a - b))
      printf("-%d\n", a - b);
    else
      printf("+%d\n", n - (a - b));
  } else {
    if (b - a < n - (b - a))
      printf("+%d\n", b - a);
    else
      printf("-%d\n", n - (b - a));
  }
}
int main() {
  scanf("%d%d", &n, &s);
  s--;
  for (int a = 0; a < n; a++) {
    scanf("%d", &x[a].first);
    x[a].second = a;
  }
  sort(x, x + n);
  for (int a = 0; a < n; a++) {
    if (la != x[a].first) {
      y.push_back(vector<int>());
      la = x[a].first;
    }
    y.back().push_back(x[a].second);
    x[a].first = y.size() - 1;
  }
  for (int a = 0; a < y.size(); a++) {
    if (a) {
      for (int b = 0; b < y[a].size(); b++) {
        sv[y[a][b]] = INT_MAX;
        for (int c = 0; c < y[a - 1].size(); c++)
          if (tv[y[a - 1][c]] + min(abs(y[a - 1][c] - y[a][b]),
                                    n - abs(y[a - 1][c] - y[a][b])) <
              sv[y[a][b]]) {
            sf[y[a][b]] = y[a - 1][c];
            sv[y[a][b]] = tv[y[a - 1][c]] + min(abs(y[a - 1][c] - y[a][b]),
                                                n - abs(y[a - 1][c] - y[a][b]));
          }
      }
    } else {
      for (int b = 0; b < y[a].size(); b++) {
        sf[y[a][b]] = s;
        sv[y[a][b]] = min(abs(s - y[a][b]), n - abs(s - y[a][b]));
      }
    }
    if (y[a].size() == 1) {
      tv[y[a][0]] = sv[y[a][0]];
      tf[y[a][0]] = y[a][0];
    } else {
      yy.clear();
      for (int b = 0; b < y[a].size(); b++)
        yy.push_back((y[a][(b + 1) % y[a].size()] - y[a][b] + n) % n);
      for (int b = 0; b < y[a].size(); b++)
        yy.push_back((y[a][(b + 1) % y[a].size()] - y[a][b] + n) % n);
      z.clear();
      z.push_back(vector<int>());
      while (1 << (z.size() - 1) < yy.size()) z.push_back(vector<int>());
      for (int b = 0; b < yy.size(); b++) z[0].push_back(b);
      for (int b = 1; b < z.size(); b++)
        for (int c = 0; ((1 << (b)) * (c)) < yy.size(); c++) {
          z[b].push_back(z[b - 1][c * 2]);
          if (((1 << (b - 1)) * (c * 2 + 1)) < yy.size() &&
              yy[z[b - 1][c * 2 + 1]] < yy[z[b - 1][c * 2]])
            z[b][c] = z[b - 1][c * 2 + 1];
        }
      for (int b = 0; b < y[a].size(); b++) {
        tv[y[a][b]] = INT_MAX;
        for (int c = 0; c < y[a].size(); c++) {
          ta = f1(max(b, c), min(b, c) + y[a].size(), z.size() - 1, 0);
          tb = sv[y[a][c]] + n + y[a][min(b, c)] + n - y[a][max(b, c)] -
               yy[ta] * 2;
          if (tb < tv[y[a][b]]) {
            tv[y[a][b]] = tb;
            tf[y[a][b]] = y[a][c];
            tt[y[a][b]] = y[a][ta % y[a].size()] * 2;
          }
          if (y[a][b] != y[a][c]) {
            ta = f1(min(b, c), max(b, c), z.size() - 1, 0);
            tb = sv[y[a][c]] + n + y[a][max(b, c)] - y[a][min(b, c)] -
                 yy[ta] * 2;
            if (tb < tv[y[a][b]]) {
              tv[y[a][b]] = tb;
              tf[y[a][b]] = y[a][c];
              tt[y[a][b]] = y[a][ta] * 2 + 1;
            }
          }
        }
      }
    }
  }
  ta = y.back()[0];
  for (int a = 1; a < y.back().size(); a++)
    if (tv[y.back()[a]] < tv[ta]) ta = y.back()[a];
  printf("%d\n", tv[ta]);
  for (int a = y.size() - 1; a >= 0; a--) {
    aa[a] = (a == y.size() - 1) ? ta : sf[cc[a + 1]];
    bb[a] = tt[aa[a]];
    cc[a] = tf[aa[a]];
  }
  for (int a = 0; a < y.size(); a++) {
    if (a == 0)
      f2(s, cc[a]);
    else
      f2(aa[a - 1], cc[a]);
    if (y[a].size() > 1) {
      for (int b = 0; b < y[a].size(); b++) {
        if (aa[a] == y[a][b]) tc = b;
        if (bb[a] / 2 == y[a][b]) tb = b;
        if (cc[a] == y[a][b]) ta = b;
      }
      if ((bb[a] & 1) ^ (aa[a] > cc[a])) {
        while (ta != (tb + 1) % y[a].size()) {
          f2(y[a][ta], y[a][(ta - 1 + y[a].size()) % y[a].size()]);
          ta = (ta - 1 + y[a].size()) % y[a].size();
        }
        while (ta != tb) {
          f2(y[a][ta], y[a][(ta + 1) % y[a].size()]);
          ta = (ta + 1) % y[a].size();
        }
        while (ta != tc) {
          f2(y[a][ta], y[a][(ta - 1 + y[a].size()) % y[a].size()]);
          ta = (ta - 1 + y[a].size()) % y[a].size();
        }
      } else {
        while (ta != tb) {
          f2(y[a][ta], y[a][(ta + 1) % y[a].size()]);
          ta = (ta + 1) % y[a].size();
        }
        while (ta != (tb + 1) % y[a].size()) {
          f2(y[a][ta], y[a][(ta - 1 + y[a].size()) % y[a].size()]);
          ta = (ta - 1 + y[a].size()) % y[a].size();
        }
        while (ta != tc) {
          f2(y[a][ta], y[a][(ta + 1) % y[a].size()]);
          ta = (ta + 1) % y[a].size();
        }
      }
    }
  }
  return 0;
}