n = int(input()) a = list(map(int, input().split())) dummy = input() target = sorted(a, reverse=True) current = a.copy() swaps = [] for i in range(n): # Find the index j >= i where current[j] == target[i] j = i while j < n and current[j] != target[i]: j += 1 if j != i: swaps.append((i, j)) current[i], current[j] = current[j], current[i] print(len(swaps)) for u, v in swaps: print(u, v)