N = gets.to_i P = gets.split(" ").map{|s| s.to_i} cnt = 0 0.upto(N-2) {|i| while P[i] != i + 1 do j = P.index(P[i] - 1) P[i], P[j] = P[j], P[i] cnt += 1 end } puts cnt