#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ld eps = 1e-8;
template <class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) {
  return out << "(" << p.first << ", " << p.second << ")";
}
template <size_t i, class T>
ostream& print_tuple_utils(ostream& out, const T& tup) {
  if constexpr (i == tuple_size<T>::value)
    return out << ")";
  else
    return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup),
                                       tup);
}
template <class... U>
ostream& operator<<(ostream& out, const tuple<U...>& tup) {
  return print_tuple_utils<0, tuple<U...>>(out, tup);
}
template <class Con, class = decltype(begin(declval<Con>()))>
typename enable_if<!is_same<Con, string>::value, ostream&>::type operator<<(
    ostream& out, const Con& container) {
  out << "{";
  for (auto it = container.begin(); it != container.end(); ++it)
    out << (it == container.begin() ? "" : ", ") << *it;
  return out << "}";
}
const int maxn = 2222;
int n, s;
int a[maxn];
map<int, vector<int>> pos;
int forw_dist(int from, int to) {
  int ans = to - from;
  if (ans < 0) ans += n;
  return ans;
}
inline int back_dist(int from, int to) { return forw_dist(to, from); }
int dist(int from, int to) {
  return min(forw_dist(from, to), back_dist(from, to));
}
int rel_dist(int from, int to) {
  auto fd = forw_dist(from, to);
  auto bd = back_dist(from, to);
  if (fd < bd) return fd;
  return -bd;
}
vector<int>::const_iterator find_next(const vector<int>& p, int val) {
  auto it = upper_bound((p).begin(), (p).end(), val);
  if (it == p.end()) return p.begin();
  return it;
}
vector<int>::const_iterator find_prev(const vector<int>& p, int val) {
  auto it = lower_bound((p).begin(), (p).end(), val);
  if (it == p.begin()) return --p.end();
  return --it;
}
function<int(int, int)> cal_ans[] = {
    [](int start, int stop) {
      auto& stop_pos = pos[a[stop]];
      auto target = find_prev(stop_pos, start);
      return forw_dist(start, *target) + dist(*target, stop);
    },
    [](int start, int stop) {
      auto& stop_pos = pos[a[stop]];
      auto target = find_next(stop_pos, start);
      return back_dist(start, *target) + dist(*target, stop);
    },
    [](int start, int stop) {
      auto& stop_pos = pos[a[stop]];
      auto target = find_prev(stop_pos, stop);
      return forw_dist(start, *target) + back_dist(*target, stop);
    },
    [](int start, int stop) {
      auto& stop_pos = pos[a[stop]];
      auto target = find_next(stop_pos, stop);
      return back_dist(start, *target) + forw_dist(*target, stop);
    },
};
function<list<int>(int, int)> get_ans[] = {
    [](int start, int stop) -> list<int> {
      list<int> ans;
      auto target = find_prev(pos[a[stop]], start);
      int prev_pos = start;
      for (int i = start; i != *target; i = (i + 1) % n) {
        if (a[i] != a[stop]) continue;
        if (i == stop) continue;
        ans.push_back(forw_dist(prev_pos, i));
        prev_pos = i;
      }
      ans.push_back(forw_dist(prev_pos, *target));
      auto last = rel_dist(*target, stop);
      if (last) ans.push_back(last);
      return ans;
    },
    [](int start, int stop) -> list<int> {
      list<int> ans;
      auto target = find_next(pos[a[stop]], start);
      int prev_pos = start;
      for (int i = start; i != *target; i = (i - 1 + n) % n) {
        if (a[i] != a[stop]) continue;
        if (i == stop) continue;
        ans.push_back(-back_dist(prev_pos, i));
        prev_pos = i;
      }
      ans.push_back(-back_dist(prev_pos, *target));
      auto last = rel_dist(*target, stop);
      if (last) ans.push_back(last);
      return ans;
    },
    [](int start, int stop) -> list<int> {
      list<int> ans;
      auto target = find_prev(pos[a[stop]], stop);
      int prev_pos = start;
      for (int i = start; i != *target; i = (i + 1) % n) {
        if (a[i] != a[stop]) continue;
        if (i == stop) continue;
        ans.push_back(forw_dist(prev_pos, i));
        prev_pos = i;
      }
      ans.push_back(forw_dist(prev_pos, *target));
      prev_pos = *target;
      for (int i = (start - 1 + n) % n; i != stop; i = (i - 1 + n) % n) {
        if (a[i] != a[stop]) continue;
        ans.push_back(-back_dist(prev_pos, i));
        prev_pos = i;
      }
      auto last = rel_dist(prev_pos, stop);
      if (last) ans.push_back(last);
      return ans;
    },
    [](int start, int stop) -> list<int> {
      list<int> ans;
      auto target = find_next(pos[a[stop]], stop);
      int prev_pos = start;
      for (int i = start; i != *target; i = (i - 1 + n) % n) {
        if (a[i] != a[stop]) continue;
        if (i == stop) continue;
        ans.push_back(-back_dist(prev_pos, i));
        prev_pos = i;
      }
      ans.push_back(-back_dist(prev_pos, *target));
      prev_pos = *target;
      for (int i = (start + 1) % n; i != stop; i = (i + 1) % n) {
        if (a[i] != a[stop]) continue;
        ans.push_back(forw_dist(prev_pos, i));
        prev_pos = i;
      }
      auto last = rel_dist(prev_pos, stop);
      if (last) ans.push_back(last);
      return ans;
    },
};
tuple<int, int, int> dp[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  --s;
  for (int i = (int)(0); i < (int)(n); ++i) {
    cin >> a[i];
    pos[a[i]].push_back(i);
  }
  for (int i = (int)(0); i < (int)(n); ++i) {
    dp[i] = {INT_MAX, 0, 0};
  }
  for (auto u : pos.begin()->second) {
    for (int strat = (int)(0); strat < (int)(4); ++strat) {
      dp[u] = min(dp[u], {cal_ans[strat](s, u), -s - 1, strat});
    }
    if (0)
      cerr << "["
              "u"
              " = "
           << (u) << "] "
           << "["
              "dp[u]"
              " = "
           << (dp[u]) << "] " << endl;
  }
  vector<int>* prev_pos;
  for (auto& it : pos) {
    if (it.first == pos.begin()->first) {
      prev_pos = &it.second;
      continue;
    };
    if (0)
      cerr << "["
              "it.first"
              " = "
           << (it.first) << "] " << endl;
    if (0)
      cerr << "["
              "it.second"
              " = "
           << (it.second) << "] " << endl;
    if (0)
      cerr << "["
              "*prev_pos"
              " = "
           << (*prev_pos) << "] " << endl;
    for (auto stop : it.second) {
      for (auto start : *prev_pos) {
        for (int strat = (int)(0); strat < (int)(4); ++strat) {
          auto cur_ans = cal_ans[strat](start, stop) + get<0>(dp[start]);
          dp[stop] = min(dp[stop], {cur_ans, start, strat});
        }
      }
      if (0)
        cerr << "["
                "stop"
                " = "
             << (stop) << "] "
             << "["
                "dp[stop]"
                " = "
             << (dp[stop]) << "] " << endl;
    }
    prev_pos = &it.second;
  }
  pair<tuple<int, int, int>, int> ans = {{INT_MAX, 0, 0}, 0};
  for (int i = (int)(0); i < (int)(n); ++i)
    if (a[i] == pos.rbegin()->first) ans = min(ans, {dp[i], i});
  cout << get<0>(ans.first) << '\n';
  list<int> ans_list;
  for (int u = ans.second; u >= 0; u = get<1>(dp[u])) {
    int v = get<1>(dp[u]);
    if (v < 0) v = s;
    int strat = get<2>(dp[u]);
    auto cur_ans_list = get_ans[strat](v, u);
    ans_list.splice(ans_list.begin(), cur_ans_list);
  }
  for (auto i : ans_list) {
    if (i >= 0) cout << '+';
    cout << i << '\n';
  }
  return 0;
}
