n = int(input());
l = [];
f = [];

for i in range(n):
    a = int(input());
    l.append(a);

c = 0;
i = 1;
while i <= n:
    if i != l[i - 1]:
        j = l.index(i) + 1;
        k = l[(i - 1):j];
        l[(i - 1):j] = k[::-1];
        f.append([i, j]);
        c = c + 1;
    i = i + 1;

print(c);
for i in range(c):
    print(*f[i]);