n = int(input()) a = list(map(int, input().split())) dummy = int(input()) # This line is just for handling the dummy input # Create the target array sorted in decreasing order target = sorted(a, reverse=True) current = a.copy() swaps = [] for i in range(n): if current[i] == target[i]: continue # Find the position j where current[j] is target[i] for j in range(i, n): if current[j] == target[i]: break # Perform the swap current[i], current[j] = current[j], current[i] swaps.append((i, j)) # Output the result print(len(swaps)) for u, v in swaps: print(u, v)