#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]);
  }
}
