import re
import math
import decimal
import bisect

def read():
	return input().strip()

n = int(read())
ps = [0 for i in range(1, n+1)]
nadd = 10
for x in sorted([int(_) for _ in read().split()]):
	ps[x-1] = nadd
	nadd += 10
nadd = 15
for i, p in enumerate(ps):
	if p == 0:
		ps[i] = nadd
		nadd += 10

# print(ps)
swapped = True
swaps = 0
while swapped:
	swapped = False
	for i in range(n-1):
		if ps[i] > ps[i+1]:
			tmp = ps[i]
			ps[i] = ps[i+1]
			ps[i+1] = tmp
			swaps += 1
			swapped = True

print(swaps)
