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;
template <class T>
void chkmin(T &a, T b) {
  if (a > b) a = b;
}
int n, s, m;
int a[2005];
int z[2005], id[2005];
int dp[2][2005], f[2][2005];
int nxt[2005], prv[2005];
int ans;
vector<int> v[2005];
int cnt;
int pos[2005];
bool cmp(int x, int y) { return a[x] > a[y]; }
int dist(int x, int y) {
  if (x > y) swap(x, y);
  return min(y - x, n - y + x);
}
int cdist(int x, int y) {
  if (y <= x) return x - y;
  return n - y + x;
}
void calc_dp() {
  for (int x = m - 1; x >= 0; x--) {
    for (int ii = 0; ii < v[x].size(); ii++) {
      int i = v[x][ii];
      if (a[i] == m - 1)
        dp[1][i] = 0;
      else {
        dp[1][i] = INF;
        for (int j = 0; j < n; j++) {
          if (a[j] == a[i] + 1) {
            if (dp[1][i] > dp[0][j] + dist(i, j)) {
              dp[1][i] = dp[0][j] + dist(i, j);
              f[1][i] = j;
            }
          }
        }
      }
    }
    for (int ii = 0; ii < v[x].size(); ii++) {
      int i = v[x][ii];
      if (v[x].size() == 1)
        dp[0][i] = dp[1][i], f[0][i] = i;
      else {
        dp[0][i] = dp[1][prv[i]] + cdist(prv[i], i), f[0][i] = 0;
        if (dp[0][i] > dp[1][nxt[i]] + cdist(i, nxt[i])) {
          dp[0][i] = dp[1][nxt[i]] + cdist(i, nxt[i]);
          f[0][i] = 1;
        }
      }
    }
  }
  ans = INF;
  int t = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (ans > dp[0][i] + dist(i, s)) {
        ans = dp[0][i] + dist(i, s);
        t = i;
      }
    }
  }
  printf("%d\n", ans);
  if (cdist(s, t) == dist(s, t)) {
    printf("-%d\n", dist(s, t));
  } else
    printf("+%d\n", dist(s, t));
  int e = 0;
  while (1) {
    if (e == 0) {
      if (prv[t] == t)
        ;
      else {
        if (f[e][t] == 0) {
          int tl = t, tr = nxt[t];
          while (tr != t) {
            printf("+%d\n", cdist(tr, tl));
            tr = nxt[tr], tl = nxt[tl];
          }
          t = prv[t];
        } else {
          int tl = prv[t], tr = t;
          while (tl != t) {
            printf("-%d\n", cdist(tr, tl));
            tr = prv[tr], tl = prv[tl];
          }
          t = nxt[t];
        }
      }
    } else {
      if (a[t] == m - 1)
        break;
      else {
        if (cdist(t, f[e][t]) == dist(t, f[e][t])) {
          printf("-%d\n", dist(t, f[e][t]));
        } else
          printf("+%d\n", dist(t, f[e][t]));
        t = f[e][t];
      }
    }
    e ^= 1;
  }
}
int main() {
  scanf("%d %d", &n, &s);
  s--;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    z[m++] = a[i];
    id[i] = i;
  }
  sort(z, z + m);
  m = unique(z, z + m) - z;
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(z, z + m, a[i]) - z;
    v[a[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (v[a[i]].size() == 1)
      nxt[i] = prv[i] = i;
    else {
      for (int j = 1; j < n; j++) {
        if (a[(i + j) % n] == a[i]) prv[i] = (i + j) % n;
        if (a[(i + n - j) % n] == a[i]) nxt[i] = (i + n - j) % n;
      }
    }
  }
  sort(id, id + n, cmp);
  calc_dp();
  return 0;
}