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;
int n;
int s;
map<int, vector<int> > mp;
int dp[2002][2];
int rig_dist(int from, int nex) {
  if (from <= nex) {
    return nex - from;
  }
  nex += n;
  return nex - from;
}
int lef_dist(int from, int nex) { return (n - rig_dist(from, nex)) % n; }
pair<int, int> rig_near(int pos, vector<int> &v) {
  int id = lower_bound(v.begin(), v.end(), pos) - v.begin();
  if (id != v.size()) {
    return make_pair(v[id], rig_dist(pos, v[id]));
  }
  return make_pair(v[0], rig_dist(pos, v[0]));
}
pair<int, int> lef_near(int pos, vector<int> &v) {
  int id = upper_bound(v.begin(), v.end(), pos) - v.begin();
  id--;
  if (id >= 0) {
    return make_pair(v[id], lef_dist(pos, v[id]));
  }
  return make_pair(v.back(), lef_dist(pos, v.back()));
}
pair<int, int> pr[2002][2];
vector<int> path[2002][2];
bool flag[2002][2];
map<int, set<int> > mpp;
int num[2002];
void rig_walk(int from, int dist) {
  set<int> &s = mpp[num[from]];
  int cur = from;
  while (!s.empty()) {
    auto it = s.lower_bound(cur);
    if (it == s.end()) break;
    int F = rig_dist(cur, (*it));
    cur = (*it);
    if (F > dist) return;
    if (F) {
      printf("+%d\n", F);
    }
    dist -= F;
    s.erase(it);
  }
  if (dist) {
    while (!s.empty()) {
      auto it = (s.begin());
      int F = rig_dist(cur, (*it));
      if (F > dist) return;
      dist -= F;
      if (F) {
        printf("+%d\n", F);
      }
      cur = (*it);
      s.erase(it);
    }
  }
}
void lef_walk(int from, int dist) {
  int cur = from;
  set<int> &s = mpp[num[from]];
  while (!s.empty()) {
    auto it = s.upper_bound(cur);
    if (it == s.begin()) break;
    it--;
    int F = lef_dist(cur, (*it));
    cur = (*it);
    if (dist < F) return;
    dist -= F;
    s.erase(it);
    if (F) {
      printf("-%d\n", F);
    }
  }
  while (!s.empty()) {
    int nex = *s.rbegin();
    int F = lef_dist(cur, nex);
    cur = nex;
    if (dist < F) return;
    dist -= F;
    s.erase(nex);
    if (F) {
      printf("-%d\n", F);
    }
  }
}
inline void dfs(int pos, int b) {
  if (pr[pos][b].first == -1) {
    if (flag[pos][b]) {
      printf("+%d\n", dp[pos][b]);
    } else {
      printf("-%d\n", dp[pos][b]);
    }
    mpp[num[pos]].erase(pos);
    return;
  }
  if (b == 1) {
    dfs(pr[pos][b].first, pr[pos][b].second);
    int prev = pr[pos][b].first;
    int pre = path[pos][b][0];
    int go = pos;
    int dist1;
    int dist2;
    if (flag[pos][b]) {
      dist1 = lef_dist(prev, pre);
      dist2 = rig_dist(pre, go);
    } else {
      dist1 = rig_dist(prev, pre);
      dist2 = lef_dist(pre, go);
    }
    if (dist1) {
      if (flag[pos][b]) {
        lef_walk(prev, dist1);
      } else {
        rig_walk(prev, dist1);
      }
    }
    if (dist2) {
      if (flag[pos][b]) {
        rig_walk(pre, dist2);
      } else {
        lef_walk(pre, dist2);
      }
    }
  } else {
    dfs(pr[pos][b].first, pr[pos][b].second);
    int prev = pr[pos][b].first;
    int go = pos;
    if (flag[pos][b]) {
      printf("+%d\n", rig_dist(prev, go));
    } else {
      printf("-%d\n", lef_dist(prev, go));
    }
    mpp[num[go]].erase(go);
  }
}
int main() {
  cin >> n >> s;
  s--;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    mp[a].push_back(i);
    mpp[a].insert(i);
    num[i] = a;
  }
  for (int i = 0; i < 2002; i++) {
    for (int j = 0; j < 2; j++) {
      dp[i][j] = INT_MAX;
      pr[i][j] = make_pair(-1, -1);
    }
  }
  dp[lef_near(s, (*mp.begin()).second).first][0] =
      lef_near(s, (*mp.begin()).second).second;
  int D = rig_near(s, (*mp.begin()).second).second;
  int go = rig_near(s, (*mp.begin()).second).first;
  if (dp[go][0] > D) {
    dp[go][0] = D;
    flag[go][0] = true;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    vector<int> &v = (*it).second;
    for (int i = 0; i < v.size(); i++) {
      if (dp[v[i]][0] == INT_MAX) continue;
      for (int j = 0; j < v.size(); j++) {
        int cost = dp[v[i]][0] + rig_dist(v[i], v[j]);
        int nex = v[(j + 1) % v.size()];
        if (nex == v[i] && v[j] != nex) {
        } else {
          cost += lef_dist(v[j], nex);
          dp[nex][1] = min(dp[nex][1], cost);
          if (cost == dp[nex][1]) {
            pr[nex][1] = make_pair(v[i], 0);
            path[nex][1].clear();
            path[nex][1].push_back(v[j]);
            flag[nex][1] = false;
          }
        }
        cost = dp[v[i]][0] + lef_dist(v[i], v[j]);
        nex = v[(j + v.size() - 1) % v.size()];
        if (nex == v[i] && v[j] != nex) {
        } else {
          cost += rig_dist(v[j], nex);
          dp[nex][1] = min(dp[nex][1], cost);
          if (cost == dp[nex][1]) {
            pr[nex][1] = make_pair(v[i], 0);
            path[nex][1].clear();
            path[nex][1].push_back(v[j]);
            flag[nex][1] = true;
          }
        }
      }
    }
    auto nex = it;
    nex++;
    if (nex == mp.end()) continue;
    vector<int> &vv = (*nex).second;
    for (int i = 0; i < v.size(); i++) {
      if (dp[v[i]][1] == INT_MAX) continue;
      auto nex = lef_near(v[i], vv);
      int cost = dp[v[i]][1] + nex.second;
      int go = nex.first;
      dp[go][0] = min(dp[go][0], cost);
      if (cost == dp[go][0]) {
        pr[go][0] = make_pair(v[i], 1);
        flag[go][0] = false;
      }
      nex = rig_near(v[i], vv);
      cost = dp[v[i]][1] + nex.second;
      go = nex.first;
      dp[go][0] = min(dp[go][0], cost);
      if (cost == dp[go][0]) {
        pr[go][0] = make_pair(v[i], 1);
        flag[go][0] = true;
      }
    }
  }
  int ans = INT_MAX;
  auto f = mp.rbegin();
  vector<int> &v = (*f).second;
  for (int i = 0; i < v.size(); i++) {
    ans = min(ans, dp[v[i]][1]);
  }
  cout << ans << endl;
  for (int i = 0; i < v.size(); i++) {
    if (dp[v[i]][1] == ans) {
      dfs(v[i], 1);
      break;
    }
  }
  return 0;
}