toI(s=readline()) = parse(Int,s) toVI(s=readline()) = map(toI,eachsplit(s)) rep(f,n) = [f() for _ in 1:n] @enum YN Yes=1 No=0 function (@main)(ARGS) n,m = toVI() a = toVI() res = solve(n,m,a) println(length(res)) for (s,l) in res println(s," ",l) end end function solve(n,m,a) res = Tuple{Int,Int}[] now = -1 for x in a if now+1 == x s,l = res[end] res[end] = (s,l+1) else push!(res,(x,1)) end now = x end res end