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 = 2010, INF = 1e8;
int n, s, a[MAXN], b[MAXN], tot;
int f[MAXN], g[MAXN], state[MAXN];
int cost[MAXN][MAXN];
vector<int> pos[MAXN];
inline long long normaldist(int i, int j) {
  if (j >= i)
    return abs(i - j);
  else
    return n - abs(i - j);
}
inline long long reversedist(int i, int j) {
  if (j <= i)
    return abs(i - j);
  else
    return n - abs(i - j);
}
inline long long dist(int i, int j) {
  return (normaldist(i, j) < reversedist(i, j) ? normaldist(i, j)
                                               : reversedist(i, j));
}
void solve(int lvl, int st, int ed) {
  if (lvl == 1) {
    if (normaldist(s, st) <= reversedist(s, st)) {
      printf("+%d\n", normaldist(s, st));
    } else {
      printf("-%d\n", reversedist(s, st));
    }
  } else {
    int lst = 0, led = 0;
    int sz2 = pos[lvl - 1].size();
    for (long long j = (0); j <= (sz2 - 1); j++) {
      if (g[pos[lvl - 1][j]] + dist(pos[lvl - 1][j], st) == f[st]) {
        led = pos[lvl - 1][j];
        break;
      }
    }
    lst = led;
    for (long long j = (0); j <= (sz2 - 1); j++) {
      if (pos[lvl - 1][j] == led) continue;
      if (f[pos[lvl - 1][j]] + cost[pos[lvl - 1][j]][led] == g[led]) {
        lst = pos[lvl - 1][j];
        break;
      }
    }
    solve(lvl - 1, lst, led);
    if (normaldist(led, st) <= reversedist(led, st)) {
      printf("+%d\n", normaldist(led, st));
    } else {
      printf("-%d\n", reversedist(led, st));
    }
  }
  int sz = pos[lvl].size();
  if (sz == 1) return;
  if (sz == 2) {
    if (normaldist(st, ed) <= reversedist(st, ed)) {
      printf("+%d\n", normaldist(st, ed));
    } else {
      printf("-%d\n", reversedist(st, ed));
    }
    return;
  }
  int now = state[ed];
  int prev = pos[lvl][(now - 1 + sz) % sz];
  int nxt = pos[lvl][(now + 1) % sz];
  now = ed;
  if (reversedist(st, nxt) + normaldist(nxt, now) <=
      normaldist(st, prev) + reversedist(prev, now)) {
    int idx = state[st], flag = 0;
    while (idx != state[nxt]) {
      printf("-%d\n",
             reversedist(pos[lvl][idx], pos[lvl][(idx - 1 + sz) % sz]));
      idx = (idx - 1 + sz) % sz;
    }
    int cnt = 0;
    while (idx != state[now]) {
      if (idx == state[st]) flag = 1;
      if (flag)
        printf("+%d\n",
               normaldist(cnt ? pos[lvl][idx] : nxt, pos[lvl][(idx + 1) % sz]));
      if (flag) cnt++;
      idx = (idx + 1) % sz;
    }
  } else {
    int idx = state[st], flag = 0;
    while (idx != state[prev]) {
      printf("+%d\n", normaldist(pos[lvl][idx], pos[lvl][(idx + 1) % sz]));
      idx = (idx + 1) % sz;
    }
    int cnt = 0;
    while (idx != state[now]) {
      if (idx == state[st]) flag = 1;
      if (flag)
        printf("-%d\n", reversedist(cnt ? pos[lvl][idx] : prev,
                                    pos[lvl][(idx - 1 + sz) % sz]));
      if (flag) cnt++;
      idx = (idx - 1 + sz) % sz;
    }
  }
}
int main() {
  cin >> n >> s;
  for (long long i = (1); i <= (n); i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  tot = unique(b + 1, b + 1 + n) - b - 1;
  for (long long i = (1); i <= (n); i++) {
    a[i] = lower_bound(b + 1, b + 1 + tot, a[i]) - b;
    pos[a[i]].push_back(i);
    state[i] = pos[a[i]].size() - 1;
  }
  for (long long i = (1); i <= (n); i++) f[i] = g[i] = INF;
  for (long long i = (1); i <= (n); i++) {
    for (long long j = (1); j <= (n); j++) {
      if (a[i] != a[j]) continue;
      if (i == j) continue;
      int sz = pos[a[j]].size();
      if (sz == 2) {
        cost[i][j] = dist(i, j);
        continue;
      }
      int now = state[j];
      int prev = pos[a[j]][(now - 1 + sz) % sz];
      int nxt = pos[a[j]][(now + 1) % sz];
      now = j;
      cost[i][j] = (reversedist(i, nxt) + normaldist(nxt, now) <
                            normaldist(i, prev) + reversedist(prev, now)
                        ? reversedist(i, nxt) + normaldist(nxt, now)
                        : normaldist(i, prev) + reversedist(prev, now));
    }
  }
  for (long long i = (1); i <= (n); i++) {
    if (a[i] != 1) continue;
    f[i] = dist(s, i);
  }
  for (long long i = (1); i <= (tot); i++) {
    int sz = pos[i].size();
    for (long long from = (0); from <= (sz - 1); from++) {
      for (long long to = (0); to <= (sz - 1); to++) {
        if (from == to) continue;
        int st = pos[i][from], ed = pos[i][to];
        g[ed] = (g[ed] < f[st] + cost[st][ed] ? g[ed] : f[st] + cost[st][ed]);
      }
    }
    if (sz == 1) {
      int only = pos[i][0];
      g[only] = f[only];
    }
    if (i == n) break;
    int sz2 = pos[i + 1].size();
    for (long long from = (0); from <= (sz - 1); from++) {
      for (long long to = (0); to <= (sz2 - 1); to++) {
        int st = pos[i][from], ed = pos[i + 1][to];
        f[ed] = (f[ed] < g[st] + dist(st, ed) ? f[ed] : g[st] + dist(st, ed));
      }
    }
  }
  int ans = INF, st, ed;
  for (long long i = (1); i <= (n); i++) {
    if (a[i] != tot) continue;
    if (g[i] < ans) {
      ed = i;
    }
    ans = (ans < g[i] ? ans : g[i]);
  }
  st = ed;
  int sz = pos[tot].size();
  for (long long j = (0); j <= (sz - 1); j++) {
    int u = pos[tot][j];
    if (u == ed) continue;
    if (f[u] + cost[u][ed] == g[ed]) {
      st = u;
      break;
    }
  }
  cout << ans << endl;
  solve(tot, st, ed);
  return 0;
}