#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void amax(T &a, const T &b) {
  if (a < b) a = b;
}
template <class T>
vector<int> compress(const vector<T> &v, vector<T> *unq = NULL) {
  int n = v.size();
  vector<pair<T, int> > t(n);
  for (int i = 0; i < n; i++) t[i] = make_pair(v[i], i);
  sort(t.begin(), t.end());
  vector<int> r(n);
  int cur = 0;
  for (int i = 0, k = 0; i < n; i++) {
    if (t[k].first < t[i].first) k = i, cur++;
    r[t[i].second] = cur;
  }
  if (unq) {
    unq->resize(cur + 1);
    cur = 0;
    for (int i = 0; i < n; i++)
      if (i == 0 || t[i - 1].first < t[i].first) (*unq)[cur++] = t[i].first;
  }
  return r;
}
int N, S;
int A[2011];
vector<int> G[2011];
int INF;
int dp[2011][2011];
int from[2011][2011], start[2011][2011];
int n, m, a[2005], b[2][2005];
int f[2005], d[2005][2005], ans = 0x3f3f3f3f;
struct node {
  int x, id;
} p[2005];
bool cmp(node a, node b) { return a.x != b.x ? a.x < b.x : a.id < b.id; }
int cost(int a, int b) { return min(abs(a - b), N - abs(a - b)); }
void solve() {
  memset(f, 0x3f, sizeof(f)), f[0] = 0;
  n = N, m = S + 1;
  for (int i = 1; i <= n; i++) {
    d[0][i] = d[i][0] = min(i - 1, n - i + 1);
    for (int j = 1; j <= n; j++) {
      d[i][j] = abs(i - j);
      d[i][j] = min(d[i][j], n - d[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) a[(i - m + n) % n + 1] = A[i - 1];
  for (int i = 1; i <= n; i++) p[i].x = a[i], p[i].id = i;
  sort(p + 1, p + n + 1, cmp);
  m = 0, b[0][0] = 1, b[0][1] = 0;
  for (int i = 1; i <= n; i++) {
    m ^= 1;
    int t = i;
    b[m][b[m][0] = 1] = p[i].id;
    while (p[t + 1].x == p[t].x && t < n) {
      b[m][++b[m][0]] = p[++t].id;
    }
    for (int j = 1; j <= b[m ^ 1][0]; j++) {
      int u = b[m ^ 1][j], v, l;
      if (b[m][0] == 1) {
        v = p[t].id;
        f[v] = min(f[v], d[u][v] + f[u]);
      } else {
        for (int k = 2; k <= b[m][0]; k++) {
          v = b[m][k], l = b[m][k - 1];
          f[v] = min(f[v], f[u] + d[u][l] + n - (v - l));
          f[l] = min(f[l], f[u] + d[u][v] + n - (v - l));
        }
        v = b[m][1], l = b[m][b[m][0]];
        f[v] = min(f[v], f[u] + d[u][l] + l - v);
        f[l] = min(f[l], f[u] + d[u][v] + l - v);
      }
    }
    i = t;
  }
  for (int i = 1; i <= b[m][0]; i++) ans = min(ans, f[b[m][i]]);
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &N, &S);
  S--;
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%d", A + i);
  solve();
  vector<int> C = compress(vector<int>(A, A + N));
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    G[C[i]].push_back(i);
  }
  memset(dp, 0x3f, sizeof dp);
  memset(&INF, 0x3f, sizeof INF);
  dp[0][S] = 0;
  int cur = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i)
    if (G[i].size()) {
      sort(G[i].begin(), G[i].end());
      for (int k = 0, k_len = (N); k < k_len; ++k)
        if (dp[cur][k] != INF) {
          int sz = G[i].size();
          for (int j = 0, j_len = (G[i].size()); j < j_len; ++j) {
            int K[2] = {G[i][(j + sz - 1) % sz], G[i][(j + 1) % sz]};
            for (int z = 0, z_len = (2); z < z_len; ++z) {
              int cst = cost(k, G[i][j]);
              if (G[i].size() == 1u)
                ;
              else if (G[i].size() == 2u)
                cst += cost(G[i][j], K[z]);
              else if (z == 0)
                cst += N - (G[i][j] - K[z] + N) % N;
              else
                cst += N - (K[z] - G[i][j] + N) % N;
              if (dp[cur + 1][K[z]] > cst + dp[cur][k]) {
                dp[cur + 1][K[z]] = cst + dp[cur][k];
                from[cur + 1][K[z]] = k;
                start[cur + 1][K[z]] = G[i][j];
              }
            }
          }
        }
      cur++;
    }
  int T = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i)
    if (dp[cur][T] > dp[cur][i]) {
      T = i;
    }
  vector<int> ans;
  for (int i = N; i--;) {
    if (G[i].size() == 0u) continue;
    int sz = G[i].size();
    for (int j = 0, j_len = (G[i].size()); j < j_len; ++j) {
      if (G[i][j] == T) {
        int d = 0;
        if (G[i][(j + 1) % sz] == start[cur][T]) {
          d = -1;
        } else {
          d = +1;
        }
        int jj = j;
        for (int p = 0, p_len = (sz); p < p_len; ++p) {
          ans.push_back(G[i][jj]);
          jj = (jj + d + sz) % sz;
        }
        T = from[cur][T];
        break;
      }
    }
    cur--;
  }
  assert(T == S);
  ans.push_back(S);
  reverse(ans.begin(), ans.end());
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int a[] = {(ans[i + 1] - ans[i] + N) % N, (ans[i] - ans[i + 1] + N) % N};
    if (a[0] <= a[1])
      printf("+%d\n", a[0]);
    else
      printf("-%d\n", a[1]);
  }
  return 0;
}
