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;
int A[2020];
vector<int> V;
vector<int> pos[2020];
int dist[2020][2020];
int from[2020][2020];
int rev[2020];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> S;
  S--;
  for (i = 0; i < (N); i++) cin >> A[i], V.push_back(A[i]);
  V.push_back(-1 << 30);
  sort((V.begin()), (V.end()));
  V.erase(unique((V.begin()), (V.end())), V.end());
  for (i = 0; i < (N); i++) {
    A[i] = lower_bound((V.begin()), (V.end()), A[i]) - V.begin();
    pos[A[i]].push_back(i);
    pos[A[i]].push_back(N + i);
    pos[A[i]].push_back(2 * N + i);
    pos[A[i]].push_back(3 * N + i);
    pos[A[i]].push_back(4 * N + i);
  }
  pos[0].push_back(S);
  pos[0].push_back(1 * N + S);
  pos[0].push_back(2 * N + S);
  pos[0].push_back(3 * N + S);
  pos[0].push_back(4 * N + S);
  for (i = 0; i < (N + 1); i++) {
    sort((pos[i].begin()), (pos[i].end()));
    if (i)
      for (j = 0; j < (pos[i].size()); j++) rev[pos[i][j]] = j;
  }
  for (i = 0; i < (N + 1); i++)
    for (j = 0; j < (N + 1); j++) dist[i][j] = 1 << 30;
  dist[0][S] = 0;
  for (i = 0; i < (V.size() - 1); i++) {
    for (x = 0; x < (pos[i].size() / 5); x++) {
      if (pos[i + 1].size() == 5) {
        int st = pos[i][x];
        int ed = pos[i + 1][0];
        int tot = dist[i][st] + min(abs(st - ed), N - abs(st - ed));
        if (tot < dist[i + 1][ed]) {
          dist[i + 1][ed] = tot;
          from[i + 1][ed] = st;
        }
      } else {
        for (y = 0; y < (pos[i + 1].size() / 5); y++) {
          int st = pos[i][x + 2 * pos[i].size() / 5];
          int ed = pos[i + 1][y + 2 * pos[i + 1].size() / 5];
          int pre = pos[i + 1][y + 2 * pos[i + 1].size() / 5 - 1];
          int nex = pos[i + 1][y + 2 * pos[i + 1].size() / 5 + 1];
          if (ed < st) ed += N, pre += N, nex += N;
          int tot = N - (ed - st);
          if (pre > st) tot += (pre - st) * 2;
          if (nex >= st + N) {
            tot = min(tot, ed - st);
          } else {
            tot = min(tot, 2 * (N - (nex - st)) + (ed - st));
          }
          ed = pos[i + 1][y];
          tot += dist[i][pos[i][x]];
          if (tot < dist[i + 1][ed]) {
            dist[i + 1][ed] = tot;
            from[i + 1][ed] = pos[i][x];
          }
        }
      }
    }
  }
  int st = min_element(dist[V.size() - 1], dist[V.size() - 1] + N) -
           dist[V.size() - 1];
  (void)printf("%d\n", dist[V.size() - 1][st]);
  vector<int> R;
  for (i = V.size() - 1; i >= 1; i--) {
    R.push_back(st);
    st = from[i][st];
  }
  R.push_back(S);
  reverse((R.begin()), (R.end()));
  for (i = 0; i < (R.size() - 1); i++) {
    int st = 2 * N + R[i];
    int y = rev[R[i + 1]];
    int ed = pos[i + 1][y + 2 * pos[i + 1].size() / 5];
    int pre = pos[i + 1][y + 2 * pos[i + 1].size() / 5 - 1];
    int nex = pos[i + 1][y + 2 * pos[i + 1].size() / 5 + 1];
    if (st > ed) st -= N;
    int tot1 = N - (ed - st);
    if (pre > st) tot1 += (pre - st) * 2;
    int tot2 = ed - st;
    if (nex < st + N) tot2 += 2 * (N - (nex - st));
    vector<int> pat;
    pat.push_back(st);
    if (tot1 < tot2) {
      for (auto& r : pos[i + 1])
        if (r >= st && r <= pre) pat.push_back(r);
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
      for (auto& r : pos[i + 1])
        if (r >= ed && r < st + N) pat.push_back(r - N);
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
    } else {
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
      for (auto& r : pos[i + 1])
        if (r < st + N && r >= nex) pat.push_back(r - N);
      reverse((pos[i + 1].begin()), (pos[i + 1].end()));
      for (auto& r : pos[i + 1])
        if (r >= st && r <= ed) pat.push_back(r);
    }
    for (j = 0; j < (pat.size() - 1); j++) {
      x = pat[j + 1] - pat[j];
      if (x >= 0)
        (void)printf("+%d\n", x);
      else
        (void)printf("%d\n", x);
    }
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}