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 maxn = 2e3 + 10;
const int inf = 1e9 + 10;
map<int, int> Map;
int n, s, cnt = 0, a[maxn];
int lst[maxn][maxn], nxt[maxn][maxn];
int dp[maxn][maxn];
pair<int, int> f[maxn][maxn];
vector<pair<char, int> > ans;
vector<pair<int, int> > path;
void get_path(int v, int pos) {
  path.push_back(make_pair(v, pos));
  if (f[v][pos].first != -1) get_path(f[v][pos].first, f[v][pos].second);
}
int main() {
  for (int i = 0; i < maxn; i++)
    for (int j = 0; j < maxn; j++) f[i][j] = make_pair(-1, -1);
  scanf("%d%d", &n, &s);
  s--;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    Map[a[i]] = 1;
  }
  for (map<int, int>::iterator it = Map.begin(); it != Map.end(); it++)
    it->second = cnt++;
  for (int i = 0; i < n; i++) a[i] = Map[a[i]];
  for (int i = 0; i < maxn; i++)
    for (int j = 0; j < maxn; j++) dp[i][j] = inf;
  dp[0][s] = 0;
  for (int v = 0; v < cnt; v++) {
    queue<int> Q;
    bitset<maxn> vis;
    for (int i = 0; i < n; i++) {
      Q.push(i);
      vis[i] = true;
    }
    while (!Q.empty()) {
      int x = Q.front();
      Q.pop();
      vis[x] = false;
      if (dp[v][(x - 1 + n) % n] > dp[v][x] + 1) {
        dp[v][(x - 1 + n) % n] = dp[v][x] + 1;
        f[v][(x - 1 + n) % n] = make_pair(v, x);
        if (!vis[(x - 1 + n) % n]) {
          Q.push((x - 1 + n) % n);
          vis[(x - 1 + n) % n] = true;
        }
      }
      if (dp[v][(x + 1) % n] > dp[v][x] + 1) {
        dp[v][(x + 1) % n] = dp[v][x] + 1;
        f[v][(x + 1) % n] = make_pair(v, x);
        if (!vis[(x + 1) % n]) {
          Q.push((x + 1) % n);
          vis[(x + 1) % n] = true;
        }
      }
    }
    vector<int> p;
    for (int i = 0; i < n; i++)
      if (a[i] == v) p.push_back(i);
    if ((int)p.size() == 1) {
      dp[v + 1][p[0]] = dp[v][p[0]];
      f[v + 1][p[0]] = make_pair(v, p[0]);
    } else {
      for (int i = 1; i < p.size(); i++) {
        int dist = p[i] - p[i - 1];
        if (dp[v + 1][p[i]] > dp[v][p[i - 1]] + n - dist) {
          dp[v + 1][p[i]] = dp[v][p[i - 1]] + n - dist;
          f[v + 1][p[i]] = make_pair(v, p[i - 1]);
        }
        if (dp[v + 1][p[i - 1]] > dp[v][p[i]] + n - dist) {
          dp[v + 1][p[i - 1]] = dp[v][p[i]] + n - dist;
          f[v + 1][p[i - 1]] = make_pair(v, p[i]);
        }
      }
      int dist = p[0] + n - p[(int)p.size() - 1];
      if (dp[v + 1][p[0]] > dp[v][p[(int)p.size() - 1]] + n - dist) {
        dp[v + 1][p[0]] = dp[v][p[(int)p.size() - 1]] + n - dist;
        f[v + 1][p[0]] = make_pair(v, p[(int)p.size() - 1]);
      }
      if (dp[v + 1][p[(int)p.size() - 1]] > dp[v][p[0]] + n - dist) {
        dp[v + 1][p[(int)p.size() - 1]] = dp[v][p[0]] + n - dist;
        f[v + 1][p[(int)p.size() - 1]] = make_pair(v, p[0]);
      }
    }
  }
  int minval = inf, pos;
  for (int i = 0; i < n; i++) {
    if (minval > dp[cnt][i]) {
      pos = i;
      minval = dp[cnt][i];
    }
  }
  printf("%d\n", minval);
  get_path(cnt, pos);
  reverse(path.begin(), path.end());
  for (int i = 0; i < path.size(); i++) {
    int pos, id = i;
    for (int j = i; j < path.size(); j++) {
      if (path[j].first == path[i].first)
        pos = path[j].second, id = j;
      else
        break;
    }
    if (abs(pos - path[i].second) < n - abs(pos - path[i].second)) {
      ans.push_back(make_pair(pos >= path[i].second ? '+' : '-',
                              abs(pos - path[i].second)));
    } else {
      ans.push_back(make_pair(pos <= path[i].second ? '+' : '-',
                              n - abs(pos - path[i].second)));
    }
    if (id + 1 >= path.size()) break;
    int npos = path[id + 1].second, now = path[id + 1].first - 1;
    vector<int> p;
    for (int j = 0; j < n; j++)
      if (a[j] == now) p.push_back(j);
    int id1, id2;
    for (int j = 0; j < p.size(); j++)
      if (p[j] == pos) id1 = j;
    for (int j = 0; j < p.size(); j++)
      if (p[j] == npos) id2 = j;
    char c;
    int add;
    if ((int)p.size() == 2) {
      if (p[1] - p[0] < n - (p[1] - p[0])) {
        if (pos < npos)
          c = '+', add = +1;
        else
          c = '-', add = -1;
      } else {
        if (pos < npos)
          c = '-', add = -1;
        else
          c = '+', add = +1;
      }
    } else {
      if ((id1 + 1) % (int)p.size() == id2) {
        c = '-';
        add = -1;
      } else {
        c = '+';
        add = +1;
      }
    }
    int cnt = 0;
    for (int j = pos;; j = (j + add + n) % n) {
      if (a[j] == now && j != pos) {
        ans.push_back(make_pair(c, cnt));
        cnt = 0;
      }
      if (j == npos) break;
      cnt++;
    }
    i = id;
  }
  for (int i = 0; i < ans.size() - 1; i++)
    cout << ans[i].first << ans[i].second << endl;
  return 0;
}