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;
class IO {
  static const int bufSize = 1 << 18;
  char inBuf[bufSize], outBuf[bufSize];
  char *ip1 = inBuf, *ip2 = inBuf;
  int ok = 1, op1 = -1, op2 = bufSize - 1;
  template <typename T>
  __inline__ __attribute__((always_inline)) void __RI(T& x) {
    int ch = gc(), neg = 1;
    x = 0;
    for (; !(ch == EOF || isdigit(ch) || ch == '-'); ch = gc())
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    if (ch == '-') neg = -1, ch = gc();
    for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - 48) * neg;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) void __RC(T& x) {
    unsigned char ch;
    while (isspace(ch = gc()))
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    x = ch;
  }
  __inline__ __attribute__((always_inline)) void __RS(string& x) {
    char ch;
    x.clear();
    for (ch = gc(); isspace(ch); ch = gc())
      ;
    if (ch == EOF) {
      ok = 0;
      return;
    }
    for (; !isspace(ch); ch = gc()) x.push_back(ch);
  }

 public:
  __inline__ __attribute__((always_inline)) int gc() {
    return ip1 == ip2 && (ip2 = (ip1 = inBuf) + fread(inBuf, 1, bufSize, stdin),
                          ip1 == ip2)
               ? EOF
               : *ip1++;
  }
  __inline__ __attribute__((always_inline)) IO& R(char& x) {
    __RC(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& R(unsigned char& x) {
    __RC(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& R(string& x) {
    __RS(x);
    return *this;
  }
  template <typename T1, typename T2>
  __inline__ __attribute__((always_inline)) IO& R(pair<T1, T2>& x) {
    R(x.first), R(x.second);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& R(vector<T>& x) {
    for (auto& i : x) R(i);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& RA(T* a, int n) {
    for (int i = 0; i < n; ++i) R(a[i]);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& R(T& x, Args&... args) {
    R(x), R(args...);
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& RA(T* a, int n, Args... args) {
    for (int i = 0; i < n; ++i) RA(a[i], args...);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& R(T& x) {
    static_assert(is_integral<T>::value, "Unsupported types");
    if (is_integral<T>::value) __RI(x);
    return *this;
  }

 private:
  char space = ' ';
  template <typename T>
  __inline__ __attribute__((always_inline)) void __WI(T x) {
    static char buf[64];
    static int len = -1;
    if (x >= 0) {
      do {
        buf[++len] = x % 10 + 48, x /= 10;
      } while (x);
    } else {
      pc('-');
      do {
        buf[++len] = -(x % 10) + 48, x /= 10;
      } while (x);
    }
    while (len >= 0) {
      pc(buf[len]), --len;
    }
  }

 public:
  __inline__ __attribute__((always_inline)) void pc(const char& x) {
    if (op1 == op2) flush();
    outBuf[++op1] = x;
  }
  __inline__ __attribute__((always_inline)) void flush() {
    fwrite(outBuf, 1, op1 + 1, stdout), op1 = -1;
  }
  __inline__ __attribute__((always_inline)) IO& W(const char& x) {
    pc(x);
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& W(const char* x) {
    while (*x != '\0') pc(*(x++));
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& W(const string& x) {
    W(x.c_str());
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& W(const vector<T>& x) {
    for (auto& i : x) WS(i);
    WL();
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& WL() {
    W('\n');
    return *this;
  }
  template <typename T1, typename T2>
  __inline__ __attribute__((always_inline)) IO& W(const pair<T1, T2>& x) {
    WS(x.first), W(x.second);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WL(const T& x) {
    W(x), W('\n');
    return *this;
  }
  __inline__ __attribute__((always_inline)) IO& WS() {
    W(space);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WS(const T& x) {
    W(x), W(space);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& WA(T* a, int n) {
    for (int i = 0; i < n; i++) WS(a[i]);
    WL();
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& W(const T& x,
                                                  const Args&... args) {
    W(x), W(space), W(args...);
    return *this;
  }
  template <typename... Args>
  __inline__ __attribute__((always_inline)) IO& WS(const Args&... args) {
    W(args...), W(space);
    return *this;
  }
  template <typename... Args>
  __inline__ __attribute__((always_inline)) IO& WL(const Args&... args) {
    W(args...), W('\n');
    return *this;
  }
  template <typename T, typename... Args>
  __inline__ __attribute__((always_inline)) IO& WA(T* a, int n, Args... args) {
    for (int i = 0; i < n; i++) WA(a[i], args...);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& W(const T& x) {
    static_assert(is_integral<T>::value, "Unsupported types");
    if (is_integral<T>::value) __WI(x);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& operator>>(T& x) {
    R(x);
    return *this;
  }
  template <typename T>
  __inline__ __attribute__((always_inline)) IO& operator<<(const T& x) {
    W(x);
    return *this;
  }
  bool good() { return ok; }
  IO() {}
  ~IO() { flush(); }
} io;
const int32_t INF = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 1 << 11;
int64_t dp[MAXN][MAXN];
tuple<int, int, int> pre[MAXN][MAXN];
inline int calc(int x, int y, int n) {
  if (x > y) swap(x, y);
  return min(y - x, n - y + x);
}
inline int f(int x, int y, int n) { return y - x >= 0 ? y - x : y - x + n; }
int main() {
  int n, m;
  io >> n >> m;
  --m;
  vector<int> a(n);
  io >> a;
  vector<pair<int, int>> b(a.size());
  vector<vector<pair<int, int>>> v;
  for (int i = 0; i < n; i++) {
    b[i] = {a[i], i};
  }
  sort(b.begin(), b.end());
  vector<int> tmp;
  vector<vector<int>> w;
  for (int i = 0; i < n; i++) {
    if (i != 0 && b[i].first != b[i - 1].first) {
      v.emplace_back();
      for (int j = 0; j < tmp.size(); j++) {
        v.back().emplace_back(tmp[j],
                              tmp[(j - 1 < 0 ? tmp.size() - 1 : j - 1)]);
      }
      w.emplace_back(tmp);
      tmp.clear();
      tmp.emplace_back(b[i].second);
    } else
      tmp.emplace_back(b[i].second);
  }
  v.emplace_back();
  for (int j = 0; j < tmp.size(); j++) {
    v.back().emplace_back(tmp[j], tmp[(j - 1 < 0 ? tmp.size() - 1 : j - 1)]);
  }
  w.emplace_back(tmp);
  fill(pre[0], pre[0] + sizeof(pre) / sizeof(tuple<int, int, int>),
       make_tuple(-1, -1, -1));
  memset(dp, 0x3f, sizeof(dp));
  dp[0][m] = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < n; j++) {
      if (dp[i][j] == INFL) continue;
      for (int k = 0; k < v[i].size(); k++) {
        if (dp[i + 1][v[i][k].second] > f(v[i][k].first, v[i][k].second, n) +
                                            calc(j, v[i][k].first, n) +
                                            dp[i][j]) {
          dp[i + 1][v[i][k].second] = f(v[i][k].first, v[i][k].second, n) +
                                      calc(j, v[i][k].first, n) + dp[i][j];
          pre[i + 1][v[i][k].second] = {j, k, 1};
        }
        if (dp[i + 1][v[i][k].first] > f(v[i][k].first, v[i][k].second, n) +
                                           calc(j, v[i][k].second, n) +
                                           dp[i][j]) {
          dp[i + 1][v[i][k].first] = f(v[i][k].first, v[i][k].second, n) +
                                     calc(j, v[i][k].second, n) + dp[i][j];
          pre[i + 1][v[i][k].first] = {j, k, -1};
        }
      }
    }
  }
  int px = v.size(),
      py = min_element(dp[v.size()], dp[v.size()] + n) - dp[v.size()];
  io.WL(dp[v.size()][py]);
  vector<tuple<int, int, int>> ans;
  while (px) {
    ans.emplace_back(pre[px][py]);
    tie(px, py) = make_tuple(px - 1, get<0>(pre[px][py]));
  }
  reverse(ans.begin(), ans.end());
  auto output = [&](int a, int b, int directed = 0) {
    if (directed) {
      if (directed == 1) {
        io.W("+");
        if (a < b) b += n;
        io.WL(b - a);
      } else {
        io.W("-");
        if (a < b) a += n;
        io.WL(a - b);
      }
    } else {
      int o = 0;
      if (a > b) swap(a, b), o = 1;
      if (b - a < n - b + a)
        io.W("-+"[o ^ 1]).WL(b - a);
      else
        io.W("+-"[o ^ 1]).WL(n - b + a);
    }
  };
  int latest = m;
  for (int i = 0; i < v.size(); i++) {
    int k, type;
    tie(ignore, k, type) = ans[i];
    int kk = type == 1 ? k : (k - 1 + w[i].size()) % w[i].size();
    output(latest, w[i][kk]);
    for (int j = 0; j < w[i].size() - 1; j++) {
      int jj = (j * type + kk + w[i].size()) % w[i].size();
      output(w[i][jj], w[i][(jj + type + w[i].size()) % w[i].size()]);
    }
    latest = type == 1 ? v[i][k].second : v[i][k].first;
  }
  return 0;
}