#include #include #include using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int ans = 0; vector pos; void go(int cur,int to){ if(pos[cur]==to)return; go(cur-1,to); if(pos[cur-1]==to){ swap(pos[cur-1],pos[cur]); ans++; return; } } int main(){ int N; cin>>N; vector P(N); pos.resize(N); rep(i,N){ cin>>P[i]; P[i]--; pos[P[i]] = i; } for(int i=N-1;i>=0;i--){ go(i,i); } cout<