#include using namespace std; int main() { int N, M; cin >> N >> M; vector A(M); for (int i = 0; i < M; ++i) cin >> A[i]; vector> ans; int now = 0; for (int i = 1; i < M; ++i) { if (A[i - 1] + 1 != A[i]) { ans.emplace_back(A[now], i - now); now = i; } } ans.emplace_back(A[now], M - now); cout << ans.size() << endl; for (auto x : ans) cout << x.first << " " << x.second << endl; return 0; }