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 tam = 2010;
const long long MOD = 100000000000007ll;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1);
int ar[tam], n;
vector<int> nums[tam];
int le[tam], ri[tam];
pair<long long, int> fin[tam][tam];
pair<long long, int> fro[tam][tam];
int dis(int fro, int to) {
  if (fro > to) swap(fro, to);
  return min(to - fro, fro + n - to);
}
int go(int nu, int fro, int to) {
  if (fro == to) return nums[nu].size() == 1 ? 0 : n;
  if (nums[nu].size() == 2) return dis(fro, to);
  if (fro > to) swap(fro, to);
  return min(2 * (le[to] - fro) + fro + n - to,
             2 * (fro + (ri[to] > to ? n - ri[to] : -ri[to])) + to - fro);
}
string tost(int n) {
  string res = "";
  do {
    res += '0' + (n % 10);
    n /= 10;
  } while (n > 0);
  reverse((res).begin(), (res).end());
  return res;
}
int main() {
  int second;
  cin >> n >> second;
  second--;
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    st.insert(ar[i]);
  }
  int co = 0;
  map<int, int> ma;
  for (int x : st) ma[x] = co++;
  for (int i = 0; i < n; i++) {
    ar[i] = ma[ar[i]];
    nums[ar[i]].push_back(i);
  }
  for (int i = 0; i < co; i++) {
    int si = nums[i].size();
    for (int j = 0; j < si; j++) {
      le[nums[i][j]] = nums[i][(j - 1 + si) % si];
      ri[nums[i][j]] = nums[i][(j + 1) % si];
    }
  }
  for (int i = 0; i < co; i++) {
    for (int j = 0; j < nums[i].size(); j++) {
      if (i == 0)
        fro[i][j] = {dis(nums[i][j], second), 0};
      else {
        fro[i][j] = {MOD, 0};
        for (int k = 0; k < nums[i - 1].size(); k++)
          fro[i][j] =
              min(fro[i][j],
                  {fin[i - 1][k].first + dis(nums[i][j], nums[i - 1][k]), k});
      }
    }
    for (int j = 0; j < nums[i].size(); j++) {
      fin[i][j] = {MOD, 0};
      for (int k = 0; k < nums[i].size(); k++)
        fin[i][j] = min(fin[i][j],
                        {fro[i][k].first + go(i, nums[i][j], nums[i][k]), k});
    }
  }
  pair<pair<long long, int>, int> mani{{MOD, 0}, 0};
  for (int i = 0; i < nums[co - 1].size(); i++)
    mani = min(mani, {fin[co - 1][i], i});
  cout << mani.first.first << '\n';
  vector<string> res;
  string sa;
  int toto = mani.second, ir, tutu, satoto, topo;
  int rosa = 0;
  for (int titi = co - 1; titi > -1; titi--) {
    int resa = 0, resb = 0, add;
    ir = fin[titi][toto].second;
    if (nums[titi].size() > 1) {
      vector<string> va, vb;
      swap(ir, toto);
      satoto = toto;
      while (nums[titi][toto] != le[nums[titi][ir]]) {
        tutu = (toto + 1) % (int)nums[titi].size();
        if (tutu > toto)
          add = nums[titi][tutu] - nums[titi][toto];
        else
          add = nums[titi][tutu] + n - nums[titi][toto];
        resa += add;
        va.push_back("+" + tost(add));
        toto = tutu;
      }
      toto = satoto;
      topo = resa;
      while (toto != ir) {
        tutu = (toto + (int)nums[titi].size() - 1) % (int)nums[titi].size();
        if (tutu < toto)
          add = nums[titi][toto] - nums[titi][tutu] + topo;
        else
          add = nums[titi][toto] + n - nums[titi][tutu] + topo;
        resa += add;
        topo = 0;
        va.push_back("-" + tost(add));
        toto = tutu;
      }
      toto = satoto;
      while (nums[titi][toto] != ri[nums[titi][ir]]) {
        tutu = (toto + (int)nums[titi].size() - 1) % (int)nums[titi].size();
        if (tutu < toto)
          add = nums[titi][toto] - nums[titi][tutu];
        else
          add = nums[titi][toto] + n - nums[titi][tutu];
        resb += add;
        vb.push_back("-" + tost(add));
        toto = tutu;
      }
      topo = resb;
      toto = satoto;
      while (toto != ir) {
        tutu = (toto + 1) % (int)nums[titi].size();
        if (tutu > toto)
          add = nums[titi][tutu] - nums[titi][toto] + topo;
        else
          add = nums[titi][tutu] + n - nums[titi][toto] + topo;
        resb += add;
        topo = 0;
        vb.push_back("+" + tost(add));
        toto = tutu;
      }
      if (resa > resb) {
        swap(resa, resb);
        swap(va, vb);
      }
      rosa += resa;
      reverse((va).begin(), (va).end());
      for (auto cat : va) res.push_back(cat);
    }
    ir = fin[titi][toto].second;
    toto = fro[titi][ir].second;
    resa = nums[titi][ir];
    if (titi == 0)
      resb = second;
    else
      resb = nums[titi - 1][toto];
    if (resa < resb) {
      if (resb - resa < resa + n - resb) {
        rosa += resb - resa;
        res.push_back("-" + tost(resb - resa));
      } else {
        rosa += resa + n - resb;
        res.push_back("+" + tost(resa + n - resb));
      }
    } else {
      if (resa - resb < resb + n - resa) {
        rosa += resa - resb;
        res.push_back("+" + tost(resa - resb));
      } else {
        rosa += resb + n - resa;
        res.push_back("-" + tost(resb + n - resa));
      }
    }
  }
  reverse((res).begin(), (res).end());
  for (int i = 0; i < res.size(); i++) cout << res[i] << '\n';
  return 0;
}