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>
const int N = 2200;
using namespace std;
int n, s;
int ar[N];
vector<int> v;
int need_val, need_cnt;
vector<pair<int, int> > avec;
vector<int> entries[N];
int asdfasdgasdg[N], nxt[N];
map<int, int> mapp;
int dp[N][2];
pair<int, int> par[N][2];
int cnt;
void remap() {
  sort(v.begin(), v.end());
  cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    if (i > 0 && v[i] == v[i - 1]) continue;
    mapp[v[i]] = cnt;
    ++cnt;
  }
}
int get_dist(int a, int b) {
  a = abs(a - b);
  if (a > n - a) a = n - a;
  return a;
}
vector<pair<int, int> > qmoves, vec1, vec2;
int eval(int a, int b, int dir) {
  int have = 0;
  int moves = 0;
  qmoves.clear();
  int moves2 = 0;
  while (true) {
    if (ar[a] == need_val || a == b) {
      if (ar[a] == need_val) ++have;
      qmoves.push_back(make_pair(moves2, dir));
      moves2 = 0;
    }
    if (a == b) break;
    ++moves;
    ++moves2;
    a += dir;
    if (a < 0) a += n;
    if (a >= n) a -= n;
  }
  if (have < need_cnt) return 1e9;
  return moves;
}
void show(vector<pair<int, int> > v) {
  for (int i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
  cout << endl;
}
int main() {
  cin >> n >> s;
  --s;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    v.push_back(ar[i]);
  }
  remap();
  for (int i = 0; i < n; i++) {
    ar[i] = mapp[ar[i]];
  }
  for (int i = 0; i < n; i++) {
    if (entries[ar[i]].size())
      asdfasdgasdg[i] = entries[ar[i]].back(), nxt[entries[ar[i]].back()] = i,
      asdfasdgasdg[entries[ar[i]][0]] = i, nxt[i] = entries[ar[i]][0];
    entries[ar[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (entries[ar[i]].size() == 1) {
      asdfasdgasdg[i] = nxt[i] = i;
    }
  }
  for (int i = 0; i < n; i++) {
    dp[i][0] = dp[i][1] = 1e9;
  }
  for (int i = 0; i < n; i++) {
    if (ar[i] == 0) {
      dp[i][0] = get_dist(s, i);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < entries[i].size(); j++) {
      int ps = entries[i][j];
      int R = nxt[ps];
      int L = asdfasdgasdg[ps];
      if (L == ps) {
        if (dp[ps][1] > dp[ps][0]) {
          dp[ps][1] = dp[ps][0];
          par[ps][1] = make_pair(ps, 0);
        }
      }
      int dist_L;
      if (L < ps)
        dist_L = ps - L;
      else
        dist_L = ps + n - L;
      int dist_R;
      if (R > ps)
        dist_R = R - ps;
      else
        dist_R = R + n - ps;
      if (dp[L][1] > dp[ps][0] + (n - dist_L)) {
        dp[L][1] = dp[ps][0] + (n - dist_L);
        par[L][1] = make_pair(ps, 0);
      }
      if (dp[R][1] > dp[ps][0] + (n - dist_R)) {
        dp[R][1] = dp[ps][0] + (n - dist_R);
        par[R][1] = make_pair(ps, 0);
      }
    }
    for (int j = 0; j < entries[i].size(); j++) {
      int ps = entries[i][j];
      for (int q = 0; q < entries[i + 1].size(); q++) {
        int ps2 = entries[i + 1][q];
        int D = get_dist(ps2, ps);
        if (dp[ps2][0] > dp[ps][1] + D) {
          dp[ps2][0] = dp[ps][1] + D;
          par[ps2][0] = make_pair(ps, 1);
        }
      }
    }
  }
  int qi, qj;
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    if (ar[i] == cnt - 1) {
      if (dp[i][1] < ans) {
        ans = dp[i][1];
        qi = i;
        qj = 1;
      }
    }
  }
  cout << ans << endl;
  while (ar[qi] != 0 || qj != 0) {
    pair<int, int> p2 = par[qi][qj];
    if (qj == 0 && p2.second == 1) {
      need_val = -1;
      need_cnt = 0;
    } else {
      need_val = ar[qi];
      need_cnt = entries[ar[qi]].size();
    }
    int cost1 = eval(p2.first, qi, 1);
    vec1 = qmoves;
    int cost2 = eval(p2.first, qi, -1);
    vec2 = qmoves;
    reverse(vec1.begin(), vec1.end());
    reverse(vec2.begin(), vec2.end());
    if (cost1 < cost2) {
      for (int q = 0; q < vec1.size(); q++) {
        avec.push_back(vec1[q]);
      }
    } else {
      for (int q = 0; q < vec2.size(); q++) {
        avec.push_back(vec2[q]);
      }
    }
    qi = p2.first;
    qj = p2.second;
  }
  need_val = -1;
  need_cnt = 0;
  int cost1 = eval(s, qi, 1);
  vec1 = qmoves;
  int cost2 = eval(s, qi, -1);
  vec2 = qmoves;
  reverse(vec1.begin(), vec1.end());
  reverse(vec2.begin(), vec2.end());
  if (cost1 < cost2) {
    for (int q = 0; q < vec1.size(); q++) {
      avec.push_back(vec1[q]);
    }
  } else {
    for (int q = 0; q < vec2.size(); q++) {
      avec.push_back(vec2[q]);
    }
  }
  reverse(avec.begin(), avec.end());
  for (int i = 0; i < avec.size(); i++) {
    if (i != 0 && avec[i].first == 0) continue;
    if (avec[i].second == 1)
      cout << "+";
    else
      cout << "-";
    cout << avec[i].first;
    cout << endl;
  }
  cin.get();
  cin.get();
  return 0;
}