N = int(input()) P = list(map(int,input().split())) cnt = 0 Q = [0 for _ in range(N+1)] for index,p in enumerate(P): Q[p] = index flag = True while flag: flag = False for i in range(1,N): if Q[i] > Q[i+1]: Q[i],Q[i+1] = Q[i+1],Q[i] flag = True cnt += 1 break print(cnt)