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 INF = 1e9 + 7;
int N, S;
int a[2005], cnt[2005];
int l[2005][2005], r[2005][2005];
int f[2][2005][2005], prv[2][2005][2005];
vector<int> ver, ret;
int distl(int i, int j) {
  if (i >= j)
    return i - j;
  else
    return N - (j - i);
}
int distr(int i, int j) {
  if (i <= j)
    return j - i;
  else
    return N - (i - j);
}
void update(int op1, int i1, int j1, int op2, int i2, int j2, int cost) {
  if (f[op2][i2][j2] + cost < f[op1][i1][j1] || f[op1][i1][j1] == -1) {
    f[op1][i1][j1] = f[op2][i2][j2] + cost;
    prv[op1][i1][j1] = j2;
  }
}
void path(int op, int i, int j) {
  if (op || i) {
    if (op)
      path(0, i, prv[op][i][j]);
    else
      path(1, i - 1, prv[op][i][j]);
  }
  ver.push_back(j);
}
int main() {
  scanf("%d%d", &N, &S);
  for (int i = 0; i < (int)(N); ++i) scanf("%d", &a[i]);
  for (int i = 0; i < (int)(N); ++i) ver.push_back(a[i]);
  sort(ver.begin(), ver.end());
  ver.erase(unique(ver.begin(), ver.end()), ver.end());
  for (int i = 0; i < (int)(N); ++i) {
    a[i] = lower_bound(ver.begin(), ver.end(), a[i]) - ver.begin();
    cnt[a[i]]++;
  }
  memset(l, -1, sizeof(l));
  memset(r, -1, sizeof(r));
  for (int i = 0; i < (int)(N); ++i) {
    for (int j = i - 1; j != i; --j) {
      if (j < 0) j += N;
      if (j == i) break;
      if (l[i][a[j]] == -1) l[i][a[j]] = j;
    }
    for (int j = i + 1; j != i; ++j) {
      if (j >= N) j -= N;
      if (j == i) break;
      if (r[i][a[j]] == -1) r[i][a[j]] = j;
    }
  }
  memset(f, -1, sizeof(f));
  S--;
  for (int i = 0; i < (int)(N); ++i)
    if (a[i] == 0) {
      f[0][0][i] = min(distl(S, i), distr(S, i));
      prv[0][0][i] = -1;
    }
  for (int i = 0; i < (int)(ver.size()); ++i) {
    for (int j = 0; j < (int)(N); ++j)
      if (f[0][i][j] != -1) {
        if (cnt[i] == 1)
          update(1, i, j, 0, i, j, 0);
        else if (cnt[i] == 2) {
          update(1, i, l[j][i], 0, i, j, distl(j, l[j][i]));
          update(1, i, r[j][i], 0, i, j, distr(j, r[j][i]));
        } else {
          update(1, i, l[j][i], 0, i, j, N - distl(j, l[j][i]));
          update(1, i, r[j][i], 0, i, j, N - distr(j, r[j][i]));
        }
      }
    if (i == ver.size() - 1) continue;
    for (int j = 0; j < (int)(N); ++j)
      if (f[1][i][j] != -1) {
        update(0, i + 1, l[j][i + 1], 1, i, j, distl(j, l[j][i + 1]));
        update(0, i + 1, r[j][i + 1], 1, i, j, distr(j, r[j][i + 1]));
      }
  }
  int bestId = -1, best = INF;
  for (int i = 0; i < (int)(N); ++i)
    if (a[i] == ver.size() - 1) {
      if (best > f[1][a[i]][i] && f[1][a[i]][i] != -1) {
        best = f[1][a[i]][i];
        bestId = i;
      }
    }
  printf("%d\n", best);
  int siz = ver.size();
  ver.clear();
  path(1, siz - 1, bestId);
  for (int i = 0; i < (int)(ver.size()); ++i) {
    if (cnt[i / 2] == 1)
      ret.push_back(ver[i]);
    else if (cnt[i / 2] == 2)
      ret.push_back(ver[i]), ret.push_back(ver[i + 1]);
    else {
      if (f[0][i / 2][ver[i]] + N - distl(ver[i], ver[i + 1]) ==
          f[1][i / 2][ver[i + 1]]) {
        ret.push_back(ver[i]);
        for (int j = ver[i] + 1; j != ver[i]; ++j) {
          if (j >= N) j -= N;
          if (j == ver[i]) break;
          if (a[j] == i / 2) ret.push_back(j);
        }
      } else {
        ret.push_back(ver[i]);
        for (int j = ver[i] - 1; j != ver[i]; --j) {
          if (j < 0) j += N;
          if (j == ver[i]) break;
          if (a[j] == i / 2) ret.push_back(j);
        }
      }
    }
    i++;
  }
  int pos = S;
  for (int i = 0; i < (int)(ret.size()); ++i) {
    if (distl(pos, ret[i]) < distr(pos, ret[i]))
      printf("-%d\n", distl(pos, ret[i]));
    else
      printf("+%d\n", distr(pos, ret[i]));
    pos = ret[i];
  }
  return 0;
}