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 mxn = 2e3 + 5;
const int inf = 0x3f3f3f3f;
int n, s;
int a[mxn];
vector<int> vec;
vector<int> pos[mxn];
vector<vector<int> > dp[mxn][2];
vector<vector<pair<int, int> > > pr[mxn][2];
int dis(int x, int y) {
  x %= n, y %= n;
  return min(abs(x - y), n - abs(x - y));
}
int at(int i, int p) { return pos[i][p % pos[i].size()]; }
void write(int x) {
  if (x >= 0)
    printf("+%d\n", x);
  else
    printf("%d\n", x);
}
void go(int x, int y) {
  x %= n, y %= n;
  if (abs(x - y) < n - abs(x - y))
    write(y - x);
  else
    write(x < y ? -(x + n - y) : n - x + y);
}
void prt(int i, int c, int l, int r) {
  if (!i) return;
  if (l == r) {
    prt(i - 1, pr[i][c][l][r].first, pr[i][c][l][r].second,
        pr[i][c][l][r].second + pos[i - 1].size() - 1);
    int p = at(i - 1, pr[i][c][l][r].first == 0
                          ? pr[i][c][l][r].second
                          : pr[i][c][l][r].second + pos[i - 1].size() - 1);
    int q = at(i, c == 0 ? l : r);
    go(p, q);
  } else {
    prt(i, pr[i][c][l][r].first, c == 0 ? l + 1 : l, c == 1 ? r - 1 : r);
    int p = at(i, pr[i][c][l][r].first == 0 ? (c == 0 ? l + 1 : l)
                                            : (c == 1 ? r - 1 : r));
    int q = at(i, c == 0 ? l : r);
    go(p, q);
  }
}
int main() {
  scanf("%d %d", &n, &s);
  --s;
  for (int i = 0; i < (int)(n); ++i) scanf("%d", &a[i]);
  for (int i = 0; i < (int)(n); ++i) vec.push_back(a[i]);
  vec.push_back(-inf);
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0; i < (int)(n); ++i)
    pos[lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin()].push_back(i);
  pos[0].push_back(s);
  for (int i = 0; i < (int)(vec.size()); ++i) {
    for (int c = 0; c < (int)(2); ++c) {
      dp[i][c].resize(pos[i].size() << 1);
      pr[i][c].resize(pos[i].size() << 1);
      for (int j = 0; j < (int)(pos[i].size() << 1); ++j)
        dp[i][c][j].resize(pos[i].size() << 1, inf);
      for (int j = 0; j < (int)(pos[i].size() << 1); ++j)
        pr[i][c][j].resize(pos[i].size() << 1, make_pair(-1, -1));
    }
  }
  for (int l = 0; l < (pos[0].size() << 1); ++l)
    for (int r = l; r < (pos[0].size() << 1) && r - l + 1 <= pos[0].size(); ++r)
      for (int c = 0; c < (int)(2); ++c) dp[0][c][l][r] = 0;
  for (int i = 0; i < (int)(vec.size()); ++i)
    if (i) {
      vector<int> v;
      for (int j = 0; j < (int)(pos[i].size()); ++j) v.push_back(pos[i][j]);
      for (int j = 0; j < (int)(pos[i].size()); ++j) v.push_back(pos[i][j] + n);
      for (int j = 0; j < (int)(pos[i - 1].size()); ++j)
        for (int c = 0; c < (int)(2); ++c) {
          int p = at(i - 1, c == 0 ? j : j + pos[i - 1].size() - 1);
          int pre = lower_bound(v.begin(), v.end(), p) - v.begin();
          --pre;
          int suf = pre + 1;
          if (pre >= 0) {
            if (dp[i][0][pre][pre] >
                dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                    dis(p, at(i, pre))) {
              dp[i][0][pre][pre] = dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                                   dis(p, at(i, pre));
              pr[i][0][pre][pre] = make_pair(c, j);
            }
          }
          if (suf < v.size()) {
            if (dp[i][0][suf][suf] >
                dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                    dis(p, at(i, suf))) {
              dp[i][0][suf][suf] = dp[i - 1][c][j][j + pos[i - 1].size() - 1] +
                                   dis(p, at(i, suf));
              pr[i][0][suf][suf] = make_pair(c, j);
            }
          }
        }
      for (int j = 0; j < (int)(pos[i].size()); ++j) {
        if (dp[i][0][j + pos[i].size()][j + pos[i].size()] > dp[i][0][j][j]) {
          dp[i][0][j + pos[i].size()][j + pos[i].size()] = dp[i][0][j][j];
          pr[i][0][j + pos[i].size()][j + pos[i].size()] = pr[i][0][j][j];
        }
      }
      for (int j = 0; j < (int)(pos[i].size()); ++j) {
        if (dp[i][0][j][j] > dp[i][0][j + pos[i].size()][j + pos[i].size()]) {
          dp[i][0][j][j] = dp[i][0][j + pos[i].size()][j + pos[i].size()];
          pr[i][0][j][j] = pr[i][0][j + pos[i].size()][j + pos[i].size()];
        }
      }
      for (int l = (int)(pos[i].size() << 1) - 1; ~l; --l) {
        for (int r = l + 1;
             r < (pos[i].size() << 1) && r - l + 1 <= pos[i].size(); ++r) {
          for (int c = 0; c < (int)(2); ++c) {
            int nl = c == 0 ? l + 1 : l;
            int nr = c == 1 ? r - 1 : r;
            for (int nc = 0; nc < (int)(2); ++nc) {
              if (dp[i][c][l][r] >
                  dp[i][nc][nl][nr] +
                      dis(at(i, nc == 0 ? nl : nr), at(i, c == 0 ? l : r))) {
                dp[i][c][l][r] =
                    dp[i][nc][nl][nr] +
                    dis(at(i, nc == 0 ? nl : nr), at(i, c == 0 ? l : r));
                pr[i][c][l][r] = make_pair(nc, -1);
              }
            }
          }
        }
      }
    }
  int ans = inf;
  pair<int, int> ansi = make_pair(-1, -1);
  for (int i = 0; i < (int)(pos[vec.size() - 1].size()); ++i)
    for (int c = 0; c < (int)(2); ++c) {
      if (ans > dp[vec.size() - 1][c][i][i + pos[vec.size() - 1].size() - 1]) {
        ans = dp[vec.size() - 1][c][i][i + pos[vec.size() - 1].size() - 1];
        ansi = make_pair(i, c);
      }
    }
  printf("%d\n", ans);
  prt(vec.size() - 1, ansi.second, ansi.first,
      ansi.first + pos[vec.size() - 1].size() - 1);
  return 0;
}