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;
template <class T>
inline void amin(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void amax(T &a, const T &b) {
  if (a < b) a = b;
}
template <class T>
vector<int> compress(const vector<T> &v, vector<T> *unq = NULL) {
  int n = v.size();
  vector<pair<T, int> > t(n);
  for (int i = 0; i < n; i++) t[i] = make_pair(v[i], i);
  sort(t.begin(), t.end());
  vector<int> r(n);
  int cur = 0;
  for (int i = 0, k = 0; i < n; i++) {
    if (t[k].first < t[i].first) k = i, cur++;
    r[t[i].second] = cur;
  }
  if (unq) {
    unq->resize(cur + 1);
    cur = 0;
    for (int i = 0; i < n; i++)
      if (i == 0 || t[i - 1].first < t[i].first) (*unq)[cur++] = t[i].first;
  }
  return r;
}
int N, S;
int A[2011];
vector<int> G[2011];
int INF;
int dp[2011][2011];
int from[2011][2011], start[2011][2011];
int n, m, a[2005], b[2][2005];
int f[2005], d[2005][2005], ans = 0x3f3f3f3f;
struct node {
  int x, id;
} p[2005];
bool cmp(node a, node b) { return a.x != b.x ? a.x < b.x : a.id < b.id; }
int cost(int a, int b) { return min(abs(a - b), N - abs(a - b)); }
void solve() {
  memset(f, 0x3f, sizeof(f)), f[0] = 0;
  n = N, m = S + 1;
  for (int i = 1; i <= n; i++) {
    d[0][i] = d[i][0] = min(i - 1, n - i + 1);
    for (int j = 1; j <= n; j++) {
      d[i][j] = abs(i - j);
      d[i][j] = min(d[i][j], n - d[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) a[(i - m + n) % n + 1] = A[i - 1];
  for (int i = 1; i <= n; i++) p[i].x = a[i], p[i].id = i;
  sort(p + 1, p + n + 1, cmp);
  m = 0, b[0][0] = 1, b[0][1] = 0;
  for (int i = 1; i <= n; i++) {
    m ^= 1;
    int t = i;
    b[m][b[m][0] = 1] = p[i].id;
    while (p[t + 1].x == p[t].x && t < n) {
      b[m][++b[m][0]] = p[++t].id;
    }
    for (int j = 1; j <= b[m ^ 1][0]; j++) {
      int u = b[m ^ 1][j], v, l;
      if (b[m][0] == 1) {
        v = p[t].id;
        f[v] = min(f[v], d[u][v] + f[u]);
      } else {
        for (int k = 2; k <= b[m][0]; k++) {
          v = b[m][k], l = b[m][k - 1];
          f[v] = min(f[v], f[u] + d[u][l] + n - (v - l));
          f[l] = min(f[l], f[u] + d[u][v] + n - (v - l));
        }
        v = b[m][1], l = b[m][b[m][0]];
        f[v] = min(f[v], f[u] + d[u][l] + l - v);
        f[l] = min(f[l], f[u] + d[u][v] + l - v);
      }
    }
    i = t;
  }
  for (int i = 1; i <= b[m][0]; i++) ans = min(ans, f[b[m][i]]);
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &N, &S);
  S--;
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%d", A + i);
  solve();
  vector<int> C = compress(vector<int>(A, A + N));
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    G[C[i]].push_back(i);
  }
  memset(dp, 0x3f, sizeof dp);
  memset(&INF, 0x3f, sizeof INF);
  dp[0][S] = 0;
  int cur = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i)
    if (G[i].size()) {
      sort(G[i].begin(), G[i].end());
      for (int k = 0, k_len = (N); k < k_len; ++k)
        if (dp[cur][k] != INF) {
          int sz = G[i].size();
          for (int j = 0, j_len = (G[i].size()); j < j_len; ++j) {
            int K[2] = {G[i][(j + sz - 1) % sz], G[i][(j + 1) % sz]};
            for (int z = 0, z_len = (2); z < z_len; ++z) {
              int cst = cost(k, G[i][j]);
              if (G[i].size() == 1u)
                ;
              else if (G[i].size() == 2u)
                cst += cost(G[i][j], K[z]);
              else if (z == 0)
                cst += N - (G[i][j] - K[z] + N) % N;
              else
                cst += N - (K[z] - G[i][j] + N) % N;
              if (dp[cur + 1][K[z]] > cst + dp[cur][k]) {
                dp[cur + 1][K[z]] = cst + dp[cur][k];
                from[cur + 1][K[z]] = k;
                start[cur + 1][K[z]] = G[i][j];
              }
            }
          }
        }
      cur++;
    }
  int T = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i)
    if (dp[cur][T] > dp[cur][i]) {
      T = i;
    }
  vector<int> ans;
  for (int i = N; i--;) {
    if (G[i].size() == 0u) continue;
    int sz = G[i].size();
    for (int j = 0, j_len = (G[i].size()); j < j_len; ++j) {
      if (G[i][j] == T) {
        int d = 0;
        if (G[i][(j + 1) % sz] == start[cur][T]) {
          d = -1;
        } else {
          d = +1;
        }
        int jj = j;
        for (int p = 0, p_len = (sz); p < p_len; ++p) {
          ans.push_back(G[i][jj]);
          jj = (jj + d + sz) % sz;
        }
        T = from[cur][T];
        break;
      }
    }
    cur--;
  }
  assert(T == S);
  ans.push_back(S);
  reverse(ans.begin(), ans.end());
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int a[] = {(ans[i + 1] - ans[i] + N) % N, (ans[i] - ans[i + 1] + N) % N};
    if (a[0] <= a[1])
      printf("+%d\n", a[0]);
    else
      printf("-%d\n", a[1]);
  }
  return 0;
}