#include <bits/stdc++.h>
using namespace std;
int n;
int s;
map<int, vector<int> > mp;
int dp[2002][2];
int rig_dist(int from, int nex) {
  if (from <= nex) {
    return nex - from;
  }
  nex += n;
  return nex - from;
}
int lef_dist(int from, int nex) { return (n - rig_dist(from, nex)) % n; }
pair<int, int> rig_near(int pos, vector<int> &v) {
  int id = lower_bound(v.begin(), v.end(), pos) - v.begin();
  if (id != v.size()) {
    return make_pair(v[id], rig_dist(pos, v[id]));
  }
  return make_pair(v[0], rig_dist(pos, v[0]));
}
pair<int, int> lef_near(int pos, vector<int> &v) {
  int id = upper_bound(v.begin(), v.end(), pos) - v.begin();
  id--;
  if (id >= 0) {
    return make_pair(v[id], lef_dist(pos, v[id]));
  }
  return make_pair(v.back(), lef_dist(pos, v.back()));
}
pair<int, int> pr[2002][2];
vector<int> path[2002][2];
bool flag[2002][2];
map<int, set<int> > mpp;
int num[2002];
void rig_walk(int from, int dist) {
  set<int> &s = mpp[num[from]];
  int cur = from;
  while (!s.empty()) {
    auto it = s.lower_bound(cur);
    if (it == s.end()) break;
    int F = rig_dist(cur, (*it));
    cur = (*it);
    if (F > dist) return;
    if (F) {
      printf("+%d\n", F);
    }
    dist -= F;
    s.erase(it);
  }
  if (dist) {
    while (!s.empty()) {
      auto it = (s.begin());
      int F = rig_dist(cur, (*it));
      if (F > dist) return;
      dist -= F;
      if (F) {
        printf("+%d\n", F);
      }
      cur = (*it);
      s.erase(it);
    }
  }
}
void lef_walk(int from, int dist) {
  int cur = from;
  set<int> &s = mpp[num[from]];
  while (!s.empty()) {
    auto it = s.upper_bound(cur);
    if (it == s.begin()) break;
    it--;
    int F = lef_dist(cur, (*it));
    cur = (*it);
    if (dist < F) return;
    dist -= F;
    s.erase(it);
    if (F) {
      printf("-%d\n", F);
    }
  }
  while (!s.empty()) {
    int nex = *s.rbegin();
    int F = lef_dist(cur, nex);
    cur = nex;
    if (dist < F) return;
    dist -= F;
    s.erase(nex);
    if (F) {
      printf("-%d\n", F);
    }
  }
}
inline void dfs(int pos, int b) {
  if (pr[pos][b].first == -1) {
    if (flag[pos][b]) {
      printf("+%d\n", dp[pos][b]);
    } else {
      printf("-%d\n", dp[pos][b]);
    }
    mpp[num[pos]].erase(pos);
    return;
  }
  if (b == 1) {
    dfs(pr[pos][b].first, pr[pos][b].second);
    int prev = pr[pos][b].first;
    int pre = path[pos][b][0];
    int go = pos;
    int dist1;
    int dist2;
    if (flag[pos][b]) {
      dist1 = lef_dist(prev, pre);
      dist2 = rig_dist(pre, go);
    } else {
      dist1 = rig_dist(prev, pre);
      dist2 = lef_dist(pre, go);
    }
    if (dist1) {
      if (flag[pos][b]) {
        lef_walk(prev, dist1);
      } else {
        rig_walk(prev, dist1);
      }
    }
    if (dist2) {
      if (flag[pos][b]) {
        rig_walk(pre, dist2);
      } else {
        lef_walk(pre, dist2);
      }
    }
  } else {
    dfs(pr[pos][b].first, pr[pos][b].second);
    int prev = pr[pos][b].first;
    int go = pos;
    if (flag[pos][b]) {
      printf("+%d\n", rig_dist(prev, go));
    } else {
      printf("-%d\n", lef_dist(prev, go));
    }
    mpp[num[go]].erase(go);
  }
}
int main() {
  cin >> n >> s;
  s--;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    mp[a].push_back(i);
    mpp[a].insert(i);
    num[i] = a;
  }
  for (int i = 0; i < 2002; i++) {
    for (int j = 0; j < 2; j++) {
      dp[i][j] = INT_MAX;
      pr[i][j] = make_pair(-1, -1);
    }
  }
  dp[lef_near(s, (*mp.begin()).second).first][0] =
      lef_near(s, (*mp.begin()).second).second;
  int D = rig_near(s, (*mp.begin()).second).second;
  int go = rig_near(s, (*mp.begin()).second).first;
  if (dp[go][0] > D) {
    dp[go][0] = D;
    flag[go][0] = true;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    vector<int> &v = (*it).second;
    for (int i = 0; i < v.size(); i++) {
      if (dp[v[i]][0] == INT_MAX) continue;
      for (int j = 0; j < v.size(); j++) {
        int cost = dp[v[i]][0] + rig_dist(v[i], v[j]);
        int nex = v[(j + 1) % v.size()];
        if (nex == v[i] && v[j] != nex) {
        } else {
          cost += lef_dist(v[j], nex);
          dp[nex][1] = min(dp[nex][1], cost);
          if (cost == dp[nex][1]) {
            pr[nex][1] = make_pair(v[i], 0);
            path[nex][1].clear();
            path[nex][1].push_back(v[j]);
            flag[nex][1] = false;
          }
        }
        cost = dp[v[i]][0] + lef_dist(v[i], v[j]);
        nex = v[(j + v.size() - 1) % v.size()];
        if (nex == v[i] && v[j] != nex) {
        } else {
          cost += rig_dist(v[j], nex);
          dp[nex][1] = min(dp[nex][1], cost);
          if (cost == dp[nex][1]) {
            pr[nex][1] = make_pair(v[i], 0);
            path[nex][1].clear();
            path[nex][1].push_back(v[j]);
            flag[nex][1] = true;
          }
        }
      }
    }
    auto nex = it;
    nex++;
    if (nex == mp.end()) continue;
    vector<int> &vv = (*nex).second;
    for (int i = 0; i < v.size(); i++) {
      if (dp[v[i]][1] == INT_MAX) continue;
      auto nex = lef_near(v[i], vv);
      int cost = dp[v[i]][1] + nex.second;
      int go = nex.first;
      dp[go][0] = min(dp[go][0], cost);
      if (cost == dp[go][0]) {
        pr[go][0] = make_pair(v[i], 1);
        flag[go][0] = false;
      }
      nex = rig_near(v[i], vv);
      cost = dp[v[i]][1] + nex.second;
      go = nex.first;
      dp[go][0] = min(dp[go][0], cost);
      if (cost == dp[go][0]) {
        pr[go][0] = make_pair(v[i], 1);
        flag[go][0] = true;
      }
    }
  }
  int ans = INT_MAX;
  auto f = mp.rbegin();
  vector<int> &v = (*f).second;
  for (int i = 0; i < v.size(); i++) {
    ans = min(ans, dp[v[i]][1]);
  }
  cout << ans << endl;
  for (int i = 0; i < v.size(); i++) {
    if (dp[v[i]][1] == ans) {
      dfs(v[i], 1);
      break;
    }
  }
  return 0;
}
