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 double EPS = 1e-9;
const int MAXN = 2e3 + 10;
const int INF = 1e9;
const int LEFT = 0;
const int RIGHT = 1;
int a[MAXN];
int ca[MAXN];
int n, s;
int dp[MAXN][2];
vector<int> c;
vector<int> pos[MAXN];
int dir[MAXN];
bool read() {
  if (scanf("%d%d", &n, &s) < 2) {
    return false;
  }
  for (int i = 0; i < (int)n; ++i) {
    scanf("%d", &a[i]);
  }
  return true;
}
int dist_right(int i, int j) { return (j - i + n) % n; }
int dist_left(int i, int j) { return (i - j + n) % n; }
int dist(int i, int j) { return min(dist_left(i, j), dist_right(i, j)); }
void calc(int i, int w) {
  int& res = dp[i][w];
  res = INF;
  if (w == 1) {
    if (ca[i] == ((int)(c).size()) - 1) {
      res = 0;
      return;
    }
    for (int j = 0; j < (int)n; ++j) {
      if (ca[j] == ca[i] + 1) {
        res = min(res, dist(i, j) + dp[j][0]);
      }
    }
  } else {
    const vector<int>& p = pos[ca[i]];
    int my_pos = lower_bound(begin(p), end(p), i) - p.begin();
    int jj = my_pos;
    for (int it = 0; it < (int)((int)(p).size()); ++it) {
      int ri = p[(jj + 1) % ((int)(p).size())];
      int cur = dist_right(i, p[jj]) + dist_left(p[jj], ri);
      res = min(res, cur + dp[ri][1]);
      jj = (jj + 1) % ((int)(p).size());
    }
    jj = my_pos;
    for (int it = 0; it < (int)((int)(p).size()); ++it) {
      int li = p[(jj - 1 + ((int)(p).size())) % ((int)(p).size())];
      int cur = dist_left(i, p[jj]) + dist_right(p[jj], li);
      res = min(res, cur + dp[li][1]);
      jj = (jj - 1 + ((int)(p).size())) % ((int)(p).size());
    }
  }
}
void restore(int i, int w, vector<pair<int, int> >& ans) {
  int res = dp[i][w];
  if (w == 1 || ((int)(pos[ca[i]]).size()) == 1) {
    if (ca[i] == ((int)(c).size()) - 1) {
      return;
    }
    for (int j = 0; j < (int)n; ++j) {
      if (ca[j] == ca[i] + 1 && res == dist(i, j) + dp[j][0]) {
        dir[((int)(ans).size())] = -1;
        ans.push_back(make_pair(i, j));
        restore(j, 0, ans);
        return;
      }
    }
    assert(false);
  } else {
    const vector<int>& p = pos[ca[i]];
    int my_pos = lower_bound(begin(p), end(p), i) - p.begin();
    int jj = my_pos;
    for (int it = 0; it < (int)((int)(p).size()); ++it) {
      int ri = p[(jj + 1) % ((int)(p).size())];
      int cur = dist_right(i, p[jj]) + dist_left(p[jj], ri);
      if (res == cur + dp[ri][1]) {
        for (int j = my_pos; j != jj; j = (j + 1) % ((int)(p).size())) {
          int start = p[j];
          int end = p[(j + 1) % ((int)(p).size())];
          dir[((int)(ans).size())] = RIGHT;
          ans.push_back(make_pair(start, end));
        }
        if ((jj + 1) % ((int)(p).size()) == my_pos) {
          restore(p[jj], 1, ans);
          return;
        }
        dir[((int)(ans).size())] = LEFT;
        ans.push_back(make_pair(
            p[jj], p[(my_pos - 1 + ((int)(p).size())) % ((int)(p).size())]));
        for (int j = (my_pos - 1 + ((int)(p).size())) % ((int)(p).size());;
             j = (j - 1 + ((int)(p).size())) % ((int)(p).size())) {
          int start = p[j];
          int end = p[(j - 1 + ((int)(p).size())) % ((int)(p).size())];
          if (end == p[jj]) {
            break;
          }
          dir[((int)(ans).size())] = LEFT;
          ans.push_back(make_pair(start, end));
        }
        restore(ri, 1, ans);
        return;
      }
      jj = (jj + 1) % ((int)(p).size());
    }
    jj = my_pos;
    for (int it = 0; it < (int)((int)(p).size()); ++it) {
      int li = p[(jj - 1 + ((int)(p).size())) % ((int)(p).size())];
      int cur = dist_left(i, p[jj]) + dist_right(p[jj], li);
      if (res == cur + dp[li][1]) {
        for (int j = my_pos; j != jj;
             j = (j - 1 + ((int)(p).size())) % ((int)(p).size())) {
          int start = p[j];
          int end = p[(j - 1 + ((int)(p).size())) % ((int)(p).size())];
          dir[((int)(ans).size())] = LEFT;
          ans.push_back(make_pair(start, end));
        }
        if ((my_pos + 1) % ((int)(p).size()) == jj) {
          restore(p[jj], 1, ans);
          return;
        }
        dir[((int)(ans).size())] = RIGHT;
        ans.push_back(make_pair(p[jj], p[(my_pos + 1) % ((int)(p).size())]));
        for (int j = (my_pos + 1) % ((int)(p).size());;
             j = (j + 1) % ((int)(p).size())) {
          int start = p[j];
          int end = p[(j + 1) % ((int)(p).size())];
          if (end == p[jj]) {
            break;
          }
          dir[((int)(ans).size())] = RIGHT;
          ans.push_back(make_pair(start, end));
        }
        restore(li, 1, ans);
        return;
      }
      jj = (jj - 1 + ((int)(p).size())) % ((int)(p).size());
    }
    assert(false);
  }
}
int print_go(int i, int j, int d) {
  int x = -1;
  if (d == LEFT) {
    x = (i - j + n) % n;
    printf("-%d\n", x);
    return -x;
  }
  if (d == RIGHT) {
    x = (j - i + n) % n;
    printf("+%d\n", x);
  }
  if (d == -1) {
    if (dist_left(i, j) < dist_right(i, j)) {
      x = (i - j + n) % n;
      printf("-%d\n", x);
      return -x;
    } else {
      x = (j - i + n) % n;
      printf("+%d\n", x);
    }
  }
  return x;
}
void print_path(vector<pair<int, int> > ans) {
  int p = s;
  for (int i = 0; i < (int)((int)(ans).size()); ++i) {
    int x = print_go(ans[i].first, ans[i].second, dir[i]);
  }
}
void solve() {
  --s;
  c.clear();
  for (int i = 0; i < (int)n; ++i) {
    c.push_back(a[i]);
  }
  sort(begin(c), end(c));
  c.resize(unique(begin(c), end(c)) - c.begin());
  for (int i = 0; i < (int)n; ++i) {
    ca[i] = lower_bound(begin(c), end(c), a[i]) - c.begin();
    pos[ca[i]].push_back(i);
  }
  for (int val = ((int)((int)(c).size())) - 1; val >= 0; --val) {
    for (int w = ((int)2) - 1; w >= 0; --w) {
      for (int p : pos[val]) {
        calc(p, w);
      }
    }
  }
  int min_i = -1;
  int min_dist = INF;
  for (int i = 0; i < (int)n; ++i) {
    int cur_dist = dp[i][0] + dist(s, i);
    if (ca[i] == 0 && cur_dist < min_dist) {
      min_dist = cur_dist;
      min_i = i;
    }
  }
  printf("%d\n", min_dist);
  vector<pair<int, int> > ans;
  dir[0] = -1;
  ans.push_back(make_pair(s, min_i));
  restore(min_i, 0, ans);
  print_path(ans);
}
int main() {
  while (read()) {
    solve();
  }
  return 0;
}