#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
int dp[maxn][maxn];
int from[maxn];
pair<int, int> way[maxn][maxn];
vector<int> pos[maxn];
vector<pair<int, int> > num;
int n, s;
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    num.push_back(make_pair(a, i));
  }
  sort(num.begin(), num.end());
  int tmax = -1e9 - 5;
  int t = 0;
  for (int i = 0; i < num.size(); i++) {
    if (num[i].first > tmax) {
      tmax = num[i].first;
      t++;
    }
    pos[t].push_back(num[i].second);
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0][s] = 0;
  pos[0].push_back(s);
  for (int i = 1; i <= t; i++) {
    if (pos[i].size() == 1) {
      for (int k = 0; k < pos[i - 1].size(); k++) {
        int des = pos[i][0];
        int start = pos[i - 1][0];
        int dis = min(abs(start - des), n - abs(start - des));
        if (dp[i][des] > dp[i - 1][start] + dis) {
          dp[i][des] = dp[i - 1][start] + dis;
          from[des] = start;
          if (((start + dis - 1) % n) + 1 == des)
            way[i][des] = make_pair(dis, -1);
          else
            way[i][des] = make_pair(-dis, -1);
        }
      }
    }
    for (int j = 0; j < pos[i].size(); j++) {
      int des = pos[i][j];
      int npos1 = pos[i][(j - 1 + pos[i].size()) % pos[i].size()],
          npos2 = pos[i][(j + 1) % pos[i].size()];
      int od1 = (des < npos1 ? (npos1 - des) : (npos1 - des + n));
      int od2 = (des < npos2 ? (des - npos2 + n) : (des - npos2));
      for (int k = 0; k < pos[i - 1].size(); k++) {
        int start = pos[i - 1][k];
        int dis1 = min(abs(start - npos1), n - abs(start - npos1));
        int dis2 = min(abs(start - npos2), n - abs(start - npos2));
        if (dp[i][des] > dp[i - 1][start] + dis1 + od1) {
          dp[i][des] = dp[i - 1][start] + dis1 + od1;
          from[des] = start;
          if (((start + dis1 - 1) % n + 1) == npos1)
            way[i][des] = make_pair(dis1, 0);
          else
            way[i][des] = make_pair(-dis1, 0);
        }
        if (dp[i][des] > dp[i - 1][start] + dis2 + od2) {
          dp[i][des] = dp[i - 1][start] + dis2 + od2;
          from[des] = start;
          if (((start + dis2 - 1) % n + 1) == npos2)
            way[i][des] = make_pair(dis2, 1);
          else
            way[i][des] = make_pair(-dis2, 1);
        }
      }
    }
  }
  int ans = 1e9;
  int te = 0;
  vector<vector<int> > op;
  for (int i = 0; i < pos[t].size(); i++) {
    if (ans > dp[t][pos[t][i]]) {
      ans = dp[t][pos[t][i]];
      te = pos[t][i];
    }
  }
  for (int i = t; i >= 1; i--) {
    vector<int> tmp;
    int start = from[te];
    if (i == 7) {
      int as = 2;
    }
    pair<int, int> w = way[i][te];
    tmp.push_back(w.first);
    if (w.second != -1) {
      int index = lower_bound(pos[i].begin(), pos[i].end(),
                              (w.first + start - 1 + n) % n + 1) -
                  pos[i].begin();
      for (int k = 0; k < pos[i].size() - 1; k++) {
        if (w.second == 1) {
          int id1 = (index + k) % pos[i].size(),
              id2 = (index + k + 1) % pos[i].size();
          int dis = pos[i][id2] - pos[i][id1];
          if (dis < 0) dis += n;
          tmp.push_back(dis);
        } else if (w.second == 0) {
          int id1 = (index - k + pos[i].size()) % pos[i].size(),
              id2 = (index - k - 1 + pos[i].size()) % pos[i].size();
          int dis = pos[i][id1] - pos[i][id2];
          if (dis < 0) dis += n;
          tmp.push_back(-dis);
        }
      }
    }
    op.push_back(tmp);
    te = start;
  }
  cout << ans << endl;
  for (int i = op.size() - 1; i >= 0; i--) {
    for (int j = 0; j < op[i].size(); j++) {
      if (op[i][j] >= 0) printf("+");
      printf("%d\n", op[i][j]);
    }
  }
  return 0;
}
