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, s, a[2020], sz, dp[2005][2], par[2005][2];
vector<int> val, pos[2020];
vector<int> ans;
int ck[2005];
int dist(int x, int y) {
  int dis = (x - y + n) % n;
  return min(dis, n - dis);
}
int Ldist(int st, int ed) {
  if (st >= ed) return st - ed;
  return n - (ed - st);
}
int Rdist(int st, int ed) {
  if (st <= ed) return ed - st;
  return n - (st - ed);
}
void goback(int nowvar, int nowpos, int flag) {
  for (int ite = 0;; ite++) {
    if (par[nowpos][flag] == -1) {
      int RD = Rdist(s, nowpos);
      if (RD == dp[nowpos][flag])
        ans.push_back(RD);
      else
        ans.push_back(-Ldist(s, nowpos));
      break;
    }
    int prepos = par[nowpos][flag];
    int realD = abs(dp[nowpos][flag] - dp[prepos][flag ^ 1]);
    nowvar = a[nowpos];
    vector<int> tmp;
    if (realD == Rdist(prepos, nowpos)) {
      int st = prepos, ed = nowpos;
      if (st == ed) {
      } else {
        int mv = 0;
        while (1) {
          st = (st + 1) % n;
          ++mv;
          if (st == ed) {
            tmp.push_back(mv);
            break;
          }
          if (a[st] == nowvar && (flag ^ 1) == 0) {
            tmp.push_back(mv);
            mv = 0;
          }
        }
      }
    } else {
      int st = prepos, ed = nowpos;
      if (st == ed) {
      } else {
        int mv = 0;
        while (1) {
          st = (st - 1 + n) % n;
          --mv;
          if (st == ed) {
            tmp.push_back(mv);
            break;
          }
          if (a[st] == nowvar && (flag ^ 1) == 0) {
            tmp.push_back(mv);
            mv = 0;
          }
        }
      }
    }
    reverse(tmp.begin(), tmp.end());
    ans.insert(ans.end(), tmp.begin(), tmp.end());
    flag ^= 1;
    nowpos = prepos;
  }
}
int main() {
  memset(par, -1, sizeof(par));
  memset(dp, 1, sizeof(dp));
  scanf("%d %d", &n, &s);
  --s;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    val.push_back(a[i]);
  }
  sort(val.begin(), val.end());
  val.erase(unique(val.begin(), val.end()), val.end());
  sz = (int)val.size();
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(val.begin(), val.end(), a[i]) - val.begin();
    pos[a[i]].push_back(i);
  }
  for (int j = 0; j < pos[0].size(); j++) {
    dp[pos[0][j]][0] = dist(s, pos[0][j]);
  }
  for (int x = 0; x < sz; x++) {
    if ((int)pos[x].size() == 1) {
      dp[pos[x][0]][1] = dp[pos[x][0]][0];
      par[pos[x][0]][1] = pos[x][0];
    } else {
      for (int j = 0; j < pos[x].size(); j++) {
        int k = (j - 1 + (int)pos[x].size()) % (int)pos[x].size();
        if ((int)pos[x].size() == 2) {
          if (dp[pos[x][k]][1] >
              dp[pos[x][j]][0] + dist(pos[x][j], pos[x][k])) {
            dp[pos[x][k]][1] = dp[pos[x][j]][0] + dist(pos[x][j], pos[x][k]);
            par[pos[x][k]][1] = pos[x][j];
          }
        } else {
          if (dp[pos[x][k]][1] >
              dp[pos[x][j]][0] + Rdist(pos[x][j], pos[x][k])) {
            dp[pos[x][k]][1] = dp[pos[x][j]][0] + Rdist(pos[x][j], pos[x][k]);
            par[pos[x][k]][1] = pos[x][j];
          }
        }
        k = (j + 1) % (int)pos[x].size();
        if ((int)pos[x].size() == 2) {
          if (dp[pos[x][k]][1] >
              dp[pos[x][j]][0] + dist(pos[x][j], pos[x][k])) {
            dp[pos[x][k]][1] = dp[pos[x][j]][0] + dist(pos[x][j], pos[x][k]);
            par[pos[x][k]][1] = pos[x][j];
          }
        } else {
          if (dp[pos[x][k]][1] >
              dp[pos[x][j]][0] + Ldist(pos[x][j], pos[x][k])) {
            dp[pos[x][k]][1] = dp[pos[x][j]][0] + Ldist(pos[x][j], pos[x][k]);
            par[pos[x][k]][1] = pos[x][j];
          }
        }
      }
    }
    for (int j = 0; j < pos[x].size(); j++) {
      for (int k = 0; k < pos[x + 1].size(); k++) {
        if (dp[pos[x + 1][k]][0] >
            dp[pos[x][j]][1] + dist(pos[x][j], pos[x + 1][k])) {
          dp[pos[x + 1][k]][0] =
              dp[pos[x][j]][1] + dist(pos[x][j], pos[x + 1][k]);
          par[pos[x + 1][k]][0] = pos[x][j];
        }
      }
    }
  }
  int mini = 1e9;
  int pp = -1;
  for (int j = 0; j < pos[sz - 1].size(); j++) {
    if (mini > dp[pos[sz - 1][j]][1]) {
      mini = dp[pos[sz - 1][j]][1];
      pp = pos[sz - 1][j];
    }
  }
  printf("%d\n", mini);
  goback(sz - 1, pp, 1);
  for (int i = (int)ans.size() - 1; i >= 0; i--) {
    if (ans[i] >= 0)
      printf("+%d\n", ans[i]);
    else
      printf("%d\n", ans[i]);
  }
}