#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; template using V=vector; template using VV=V>; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,m; cin>>n>>m; V S(m); rep(i,m){ cin>>S[i]; S[i]--; } V A(n); rep(i,n) A[i]=i; set> s; rep(i,m){ int a=A[S[i]],b=A[S[i]+1]; if(a>b) swap(a,b); s.insert({a,b}); swap(A[S[i]],A[S[i]+1]); } cout<