#include using namespace std; using ll = long long; bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; } bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; } template vector> run_length_encoding(const vector &v) { vector> res; for (const auto &x : v) { if (res.empty() || res.back().first != x) { res.emplace_back(x, 0); } res.back().second++; } return res; } vector> run_length_encoding(const string &s) { return run_length_encoding(vector(s.begin(), s.end())); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector A(M); for (int i = 0; i < M; i++) cin >> A[i], A[i] -= i; auto P = run_length_encoding(A); cout << P.size() << '\n'; int k = 0; for (auto [a, l] : P) { cout << a + k << ' ' << l << '\n'; k += l; } }