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 N = 2020;
int dp[N][N];
int a[N << 1];
map<int, int> mp;
int pre[N][N], nxt[N][N];
int dir[N], path[N][2], only[N], sp[N];
bool vis[N];
bool update(int &x, int y) {
  if (x == -1 || x > y) {
    x = y;
    return true;
  }
  return false;
}
bool on_clockwise(int x, int y, int n, int p) {
  if (x == y) return p == x;
  if (x < y)
    return p <= y && p >= x;
  else
    return p >= x || p <= y;
}
int get_clock(int x, int y, int n) {
  if (x <= y)
    return y - x;
  else
    return n - x + y;
}
int get_counter(int x, int y, int n) {
  if (x >= y)
    return x - y;
  else {
    return x + n - y;
  }
}
bool on_counter(int x, int y, int n, int p) {
  if (x == y) return p == x;
  if (x < y) {
    return p <= x || p >= y;
  } else {
    return p <= x && p >= y;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = 1;
  }
  int cnt = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
    it->second = ++cnt;
  for (int i = 1; i <= n; i++) a[i + n] = a[i] = mp[a[i]];
  for (int i = 1; i <= cnt; i++) {
    int last = -1;
    for (int j = 1; j <= n; j++) {
      if (a[j] == i) last = j;
    }
    for (int j = 1; j <= n; j++) {
      pre[i][j] = last;
      if (a[j] == i) last = j;
    }
    for (int j = n; j >= 1; j--)
      if (a[j] == i) last = j;
    for (int j = n; j >= 1; j--) {
      nxt[i][j] = last;
      if (a[j] == i) last = j;
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[0][m] = 0;
  for (int i = 0; i < cnt; i++) {
    int f = 0, c[N], pos[N];
    for (int j = 1; j <= n; j++)
      if (a[j] == i + 1) {
        c[++f] = j;
        pos[j] = f;
      }
    for (int j = 1; j <= n; j++) {
      if (dp[i][j] == -1) continue;
      if (f == 1) {
        if (update(dp[i + 1][c[f]], dp[i][j] + min(get_clock(j, c[1], n),
                                                   get_counter(j, c[1], n)))) {
          only[c[f]] = true;
          path[c[f]][0] = j;
          if (get_counter(j, c[1], n) <= get_clock(j, c[1], n))
            dir[c[f]] = 1;
          else
            dir[c[f]] = 0;
        }
        continue;
      }
      for (int k = 1; k <= f; k++) {
        int cost = get_clock(j, c[k], n);
        if (c[k] == j) cost = 0;
        int p = nxt[i + 1][c[k]];
        if (c[k] == j && pre[i + 1][c[k]] != p) continue;
        if (on_clockwise(j, c[k], n, p)) {
          if (update(dp[i + 1][c[k]], dp[i][j] + cost)) {
            path[c[k]][0] = j;
            path[c[k]][1] = c[k];
            dir[c[k]] = 0;
            sp[c[k]] = 1;
          }
        } else {
          if (update(dp[i + 1][p], dp[i][j] + cost + get_counter(c[k], p, n))) {
            path[p][0] = j;
            path[p][1] = c[k];
            dir[p] = 0;
            sp[p] = 0;
          }
        }
      }
      for (int k = 1; k <= f; k++) {
        int cost = get_counter(j, c[k], n);
        if (c[k] == j) cost = 0;
        int p = pre[i + 1][c[k]];
        if (c[k] == j && nxt[i + 1][c[k]] != p) continue;
        if (on_counter(j, c[k], n, p)) {
          if (update(dp[i + 1][c[k]], dp[i][j] + cost)) {
            path[c[k]][0] = j;
            path[c[k]][1] = c[k];
            dir[c[k]] = 1;
            sp[c[k]] = 1;
          }
        } else {
          if (update(dp[i + 1][p], dp[i][j] + cost + get_clock(c[k], p, n))) {
            path[p][0] = j;
            path[p][1] = c[k];
            dir[p] = 1;
            sp[p] = 0;
          }
        }
      }
    }
  }
  int ans = -1, pos = -1;
  for (int i = 1; i <= n; i++)
    if (dp[cnt][i] != -1) {
      if (update(ans, dp[cnt][i])) {
        pos = i;
      }
    }
  deque<int> op, len;
  int v = cnt;
  while (v--) {
    stack<int> _op, _len;
    if (only[pos]) {
      int x = path[pos][0];
      if (get_counter(x, pos, n) <= get_clock(x, pos, n)) {
        _op.push(1);
        _len.push(get_counter(x, pos, n));
      } else {
        _op.push(0);
        _len.push(get_clock(x, pos, n));
      }
      while (!_op.empty()) {
        op.push_front(_op.top());
        _op.pop();
        len.push_front(_len.top());
        _len.pop();
      }
      pos = x;
      continue;
    }
    int x = path[pos][0], y = path[pos][1];
    if (x == y) {
      if (!vis[x]) {
        _op.push(1);
        _len.push(0);
        vis[x] = true;
      }
    }
    if (dir[pos]) {
      if (x > y) {
        for (int i = x, last = 0; i >= y; last++, i--) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(1);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      } else if (x < y) {
        int last = 0;
        for (int i = x; i >= 1; i--, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(1);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
        for (int i = n; i >= y; i--, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(1);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      }
    } else {
      if (x < y) {
        for (int i = x, last = 0; i <= y; i++, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(0);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      } else if (x > y) {
        int last = 0;
        for (int i = x; i <= n; i++, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(0);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
        for (int i = 1; i <= y; i++, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(0);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      }
    }
    if (!sp[pos]) {
      if (dir[pos]) {
        if (y < pos) {
          for (int i = y + 1, last = 1; i <= pos; i++, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(0);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        } else if (y > pos) {
          int last = 1;
          for (int i = y + 1; i <= n; i++, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(0);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
          for (int i = 1; i <= pos; i++, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(0);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        }
      } else {
        if (y > pos) {
          for (int i = y - 1, last = 1; i >= pos; i--, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(1);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        } else if (y < pos) {
          int last = 1;
          for (int i = y - 1; i >= 1; i--, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(1);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
          for (int i = n; i >= pos; i--, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(1);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        }
      }
    }
    while (!_op.empty()) {
      op.push_front(_op.top());
      _op.pop();
      len.push_front(_len.top());
      _len.pop();
    }
    pos = x;
  }
  cout << ans << endl;
  assert(op.size() == n);
  for (int i = 0; i < op.size(); i++) {
    if (op[i])
      printf("-");
    else
      printf("+");
    printf("%d\n", len[i]);
  }
  return 0;
}