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 long long MOD = 1e9 + 7;
int n, t, a[2010], to[2010], dp[2010][2010][2], num[2010][2010][2],
    tot = 1e9, Nxt[2010], Lst[2010];
pair<pair<short, short>, pair<short, short> > lst[2010][2010][2];
vector<int> vv, v[2010], ans;
map<int, int> mp;
vector<pair<pair<int, int>, int> > pre[2010], stat, res;
int getNum(pair<pair<int, int>, int> x) {
  int full = v[a[x.first.first]].size();
  x.first.first = to[x.first.first];
  x.first.second = to[x.first.second];
  if (x.second == 0) {
    if (x.first.second >= x.first.first)
      return x.first.second - x.first.first + 1;
    return full - (x.first.first - x.first.second - 1);
  } else {
    if (x.first.second <= x.first.first)
      return x.first.first - x.first.second + 1;
    return full - (x.first.second - x.first.first - 1);
  }
}
int getDist(int x, int y, int ty) {
  if (ty == 0) {
    if (y >= x) return y - x;
    return n - (x - y);
  } else {
    if (y <= x) return x - y;
    return n - (y - x);
  }
}
int main() {
  cin >> n >> t;
  --t;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]), vv.push_back(a[i]);
  sort(vv.begin(), vv.end());
  vv.erase(unique(vv.begin(), vv.end()), vv.end());
  for (int i = 0; i < vv.size(); ++i) mp[vv[i]] = i;
  for (int i = 0; i < n; ++i) {
    a[i] = mp[a[i]];
    v[a[i]].push_back(i);
    to[i] = v[a[i]].size() - 1;
  }
  for (int i = 0; i < vv.size(); ++i) {
    for (int j = 0; j < v[i].size() + 3; ++j) pre[j].clear();
    for (int j = 0; j < v[i].size(); ++j)
      for (int k = 0; k < v[i].size(); ++k)
        for (int p = 0; p < 2; ++p) {
          num[v[i][j]][v[i][k]][p] =
              getNum(make_pair(make_pair(v[i][j], v[i][k]), p));
          pre[num[v[i][j]][v[i][k]][p]].push_back(
              make_pair(make_pair(v[i][j], v[i][k]), p));
        }
    for (int j = 1; j <= v[i].size(); ++j)
      for (int k = 0; k < pre[j].size(); ++k) stat.push_back(pre[j][k]);
  }
  for (int i = 0; i < n; ++i)
    if (a[i] < vv.size() - 1) {
      for (int j = (i + 1) % n;; j = (j + 1) % n)
        if (a[j] == a[i] + 1) {
          Nxt[i] = j;
          break;
        }
      for (int j = (i - 1 + n) % n;; j = (j - 1 + n) % n)
        if (a[j] == a[i] + 1) {
          Lst[i] = j;
          break;
        }
    }
  for (int i = 0; i < n + 5; ++i)
    for (int j = 0; j < n + 5; ++j)
      for (int k = 0; k < 2; ++k) dp[i][j][k] = 1e9;
  for (int i = t, stp = 0;; i = (i + 1) % n, ++stp)
    if (a[i] == 0) {
      if (dp[i][i][0] > stp) {
        dp[i][i][0] = stp;
        lst[i][i][0] = make_pair(make_pair(-1, -1), make_pair(-1, stp));
      }
      break;
    }
  for (int i = t, stp = 0;; i = (i - 1 + n) % n, ++stp)
    if (a[i] == 0) {
      if (dp[i][i][0] > stp) {
        dp[i][i][0] = stp;
        lst[i][i][0] = make_pair(make_pair(-1, -1), make_pair(-1, -stp));
      }
      break;
    }
  for (int ii = 0; ii < stat.size(); ++ii) {
    int i = stat[ii].first.first, j = stat[ii].first.second,
        k = stat[ii].second, len = num[i][j][k];
    if (dp[i][j][k] == 1e9) continue;
    if (len == v[a[i]].size()) {
      if (a[i] == vv.size() - 1) {
        res.push_back(make_pair(make_pair(i, j), k));
        continue;
      }
      int stp = getDist(i, Nxt[i], 0);
      if (dp[Nxt[i]][Nxt[i]][0] > dp[i][j][k] + stp) {
        dp[Nxt[i]][Nxt[i]][0] = dp[i][j][k] + stp;
        lst[Nxt[i]][Nxt[i]][0] = make_pair(make_pair(i, j), make_pair(k, stp));
      }
      stp = getDist(i, Lst[i], 1);
      if (dp[Lst[i]][Lst[i]][0] > dp[i][j][k] + stp) {
        dp[Lst[i]][Lst[i]][0] = dp[i][j][k] + stp;
        lst[Lst[i]][Lst[i]][0] = make_pair(make_pair(i, j), make_pair(k, -stp));
      }
      continue;
    }
    if (k == 0) {
      int nxt = v[a[i]][(to[i] - 1 + v[a[i]].size()) % v[a[i]].size()],
          dist = getDist(i, nxt, 1);
      if (dp[nxt][j][0] > dp[i][j][k] + dist) {
        dp[nxt][j][0] = dp[i][j][k] + dist;
        lst[nxt][j][0] = make_pair(make_pair(i, j), make_pair(k, -dist));
      }
      nxt = v[a[i]][(to[j] + 1) % v[a[i]].size()];
      dist = getDist(i, nxt, 0);
      if (dp[nxt][i][1] > dp[i][j][k] + dist) {
        dp[nxt][i][1] = dp[i][j][k] + dist;
        lst[nxt][i][1] = make_pair(make_pair(i, j), make_pair(k, dist));
      }
    } else {
      int nxt = v[a[i]][(to[i] + 1) % v[a[i]].size()],
          dist = getDist(i, nxt, 0);
      if (dp[nxt][j][1] > dp[i][j][k] + dist) {
        dp[nxt][j][1] = dp[i][j][k] + dist;
        lst[nxt][j][1] = make_pair(make_pair(i, j), make_pair(k, dist));
      }
      nxt = v[a[i]][(to[j] - 1 + v[a[i]].size()) % v[a[i]].size()];
      dist = getDist(i, nxt, 1);
      if (dp[nxt][i][0] > dp[i][j][k] + dist) {
        dp[nxt][i][0] = dp[i][j][k] + dist;
        lst[nxt][i][0] = make_pair(make_pair(i, j), make_pair(k, -dist));
      }
    }
  }
  int ii, jj, kk;
  for (int i = 0; i < res.size(); ++i)
    if (dp[res[i].first.first][res[i].first.second][res[i].second] < tot) {
      tot = dp[res[i].first.first][res[i].first.second][res[i].second];
      ii = res[i].first.first;
      jj = res[i].first.second;
      kk = res[i].second;
    }
  cout << tot << endl;
  while (true) {
    ans.push_back(lst[ii][jj][kk].second.second);
    if (lst[ii][jj][kk].first.first == -1) break;
    pair<pair<int, int>, pair<int, int> > tmp = lst[ii][jj][kk];
    ii = tmp.first.first;
    jj = tmp.first.second;
    kk = tmp.second.first;
  }
  for (int i = ans.size() - 1; i >= 0; --i) {
    if (ans[i] < 0)
      printf("%d\n", ans[i]);
    else
      printf("+%d\n", ans[i]);
  }
  return 0;
}