#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
int dp[N][N];
int a[N << 1];
map<int, int> mp;
int pre[N][N], nxt[N][N];
int dir[N], path[N][2], only[N], sp[N];
bool vis[N];
bool update(int &x, int y) {
  if (x == -1 || x > y) {
    x = y;
    return true;
  }
  return false;
}
bool on_clockwise(int x, int y, int n, int p) {
  if (x == y) return p == x;
  if (x < y)
    return p <= y && p >= x;
  else
    return p >= x || p <= y;
}
int get_clock(int x, int y, int n) {
  if (x <= y)
    return y - x;
  else
    return n - x + y;
}
int get_counter(int x, int y, int n) {
  if (x >= y)
    return x - y;
  else {
    return x + n - y;
  }
}
bool on_counter(int x, int y, int n, int p) {
  if (x == y) return p == x;
  if (x < y) {
    return p <= x || p >= y;
  } else {
    return p <= x && p >= y;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = 1;
  }
  int cnt = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
    it->second = ++cnt;
  for (int i = 1; i <= n; i++) a[i + n] = a[i] = mp[a[i]];
  for (int i = 1; i <= cnt; i++) {
    int last = -1;
    for (int j = 1; j <= n; j++) {
      if (a[j] == i) last = j;
    }
    for (int j = 1; j <= n; j++) {
      pre[i][j] = last;
      if (a[j] == i) last = j;
    }
    for (int j = n; j >= 1; j--)
      if (a[j] == i) last = j;
    for (int j = n; j >= 1; j--) {
      nxt[i][j] = last;
      if (a[j] == i) last = j;
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[0][m] = 0;
  for (int i = 0; i < cnt; i++) {
    int f = 0, c[N], pos[N];
    for (int j = 1; j <= n; j++)
      if (a[j] == i + 1) {
        c[++f] = j;
        pos[j] = f;
      }
    for (int j = 1; j <= n; j++) {
      if (dp[i][j] == -1) continue;
      if (f == 1) {
        if (update(dp[i + 1][c[f]], dp[i][j] + min(get_clock(j, c[1], n),
                                                   get_counter(j, c[1], n)))) {
          only[c[f]] = true;
          path[c[f]][0] = j;
          if (get_counter(j, c[1], n) <= get_clock(j, c[1], n))
            dir[c[f]] = 1;
          else
            dir[c[f]] = 0;
        }
        continue;
      }
      for (int k = 1; k <= f; k++) {
        int cost = get_clock(j, c[k], n);
        if (c[k] == j) cost = 0;
        int p = nxt[i + 1][c[k]];
        if (c[k] == j && pre[i + 1][c[k]] != p) continue;
        if (on_clockwise(j, c[k], n, p)) {
          if (update(dp[i + 1][c[k]], dp[i][j] + cost)) {
            path[c[k]][0] = j;
            path[c[k]][1] = c[k];
            dir[c[k]] = 0;
            sp[c[k]] = 1;
          }
        } else {
          if (update(dp[i + 1][p], dp[i][j] + cost + get_counter(c[k], p, n))) {
            path[p][0] = j;
            path[p][1] = c[k];
            dir[p] = 0;
            sp[p] = 0;
          }
        }
      }
      for (int k = 1; k <= f; k++) {
        int cost = get_counter(j, c[k], n);
        if (c[k] == j) cost = 0;
        int p = pre[i + 1][c[k]];
        if (c[k] == j && nxt[i + 1][c[k]] != p) continue;
        if (on_counter(j, c[k], n, p)) {
          if (update(dp[i + 1][c[k]], dp[i][j] + cost)) {
            path[c[k]][0] = j;
            path[c[k]][1] = c[k];
            dir[c[k]] = 1;
            sp[c[k]] = 1;
          }
        } else {
          if (update(dp[i + 1][p], dp[i][j] + cost + get_clock(c[k], p, n))) {
            path[p][0] = j;
            path[p][1] = c[k];
            dir[p] = 1;
            sp[p] = 0;
          }
        }
      }
    }
  }
  int ans = -1, pos = -1;
  for (int i = 1; i <= n; i++)
    if (dp[cnt][i] != -1) {
      if (update(ans, dp[cnt][i])) {
        pos = i;
      }
    }
  deque<int> op, len;
  int v = cnt;
  while (v--) {
    stack<int> _op, _len;
    if (only[pos]) {
      int x = path[pos][0];
      if (get_counter(x, pos, n) <= get_clock(x, pos, n)) {
        _op.push(1);
        _len.push(get_counter(x, pos, n));
      } else {
        _op.push(0);
        _len.push(get_clock(x, pos, n));
      }
      while (!_op.empty()) {
        op.push_front(_op.top());
        _op.pop();
        len.push_front(_len.top());
        _len.pop();
      }
      pos = x;
      continue;
    }
    int x = path[pos][0], y = path[pos][1];
    if (x == y) {
      if (!vis[x]) {
        _op.push(1);
        _len.push(0);
        vis[x] = true;
      }
    }
    if (dir[pos]) {
      if (x > y) {
        for (int i = x, last = 0; i >= y; last++, i--) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(1);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      } else if (x < y) {
        int last = 0;
        for (int i = x; i >= 1; i--, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(1);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
        for (int i = n; i >= y; i--, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(1);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      }
    } else {
      if (x < y) {
        for (int i = x, last = 0; i <= y; i++, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(0);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      } else if (x > y) {
        int last = 0;
        for (int i = x; i <= n; i++, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(0);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
        for (int i = 1; i <= y; i++, last++) {
          if (a[i] != a[y] || vis[i]) continue;
          _op.push(0);
          _len.push(last);
          vis[i] = true;
          last = 0;
        }
      }
    }
    if (!sp[pos]) {
      if (dir[pos]) {
        if (y < pos) {
          for (int i = y + 1, last = 1; i <= pos; i++, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(0);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        } else if (y > pos) {
          int last = 1;
          for (int i = y + 1; i <= n; i++, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(0);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
          for (int i = 1; i <= pos; i++, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(0);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        }
      } else {
        if (y > pos) {
          for (int i = y - 1, last = 1; i >= pos; i--, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(1);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        } else if (y < pos) {
          int last = 1;
          for (int i = y - 1; i >= 1; i--, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(1);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
          for (int i = n; i >= pos; i--, last++) {
            if (a[i] != a[y] || vis[i]) continue;
            _op.push(1);
            _len.push(last);
            vis[i] = true;
            last = 0;
          }
        }
      }
    }
    while (!_op.empty()) {
      op.push_front(_op.top());
      _op.pop();
      len.push_front(_len.top());
      _len.pop();
    }
    pos = x;
  }
  cout << ans << endl;
  assert(op.size() == n);
  for (int i = 0; i < op.size(); i++) {
    if (op[i])
      printf("-");
    else
      printf("+");
    printf("%d\n", len[i]);
  }
  return 0;
}
