Problem: In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.

Note that in this problem you do not have to minimize the number of swaps — your task is to find any sequence that is no longer than n.

Input

The first line of the input contains integer n (1 ≤ n ≤ 3000) — the number of array elements. The second line contains elements of array: a0, a1, ..., an - 1 ( - 109 ≤ ai ≤ 109), where ai is the i-th element of the array. The elements are numerated from 0 to n - 1 from left to right. Some integers may appear in the array more than once.

Output

In the first line print k (0 ≤ k ≤ n) — the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0 ≤ i, j ≤ n - 1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are performed in the order they appear in the output, from the first to the last. It is allowed to print i = j and swap the same pair of elements multiple times.

If there are multiple answers, print any of them. It is guaranteed that at least one answer exists.

Examples

Input

5
5 2 5 1 4


Output

2
0 3
4 2


Input

6
10 20 20 40 60 60


Output

0


Input

2
101 100


Output

1
0 1

Solution (in JAVA):

Solution:

import java.awt.Point;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) throws IOException {
        //Scanner in = new Scanner(System.in);
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();

        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            int minIndex = i;
            for (int j = i + 1; j < a.length; j++) {
                if (a[j] < a[minIndex]) {
                    minIndex = j;
                }
            }
            if (minIndex != i) {
                int temp = a[i];
                a[i] = a[minIndex];
                a[minIndex] = temp;
                sum++;
                sb.append(i).append(" ").append(minIndex).append("\n");
            }
        }
        out.println(sum);

        out.println(sb.toString().trim());
        out.close();
    }

    static class Algorithm {

        static class MyString {

            static int NumberOfIterations(String str, String p) {
                int sum = 0;

                int index = 0;
                while (true) {
                    int temp = str.substring(index).indexOf(p);
                    if (temp >= 0) {
                        index += (temp + p.length());
                        sum++;
                    } else {
                        break;
                    }
                }

                return sum;
            }
        }

        static HashSet<Integer> NumbersFrom(String digitsString) {
            int[] digits = new int[10];
            for (int i = digitsString.length() - 1; i >= 0; i--) {
                if (digitsString.charAt(i) >= '0' && digitsString.charAt(i) <= '9') {
                    digits[digitsString.charAt(i) - '0']++;
                }
            }
            return NumbersFrom(digits);
        }

        static HashSet<Integer> NumbersFrom(int[] digits) {
            int maxDigit = 0;
            for (int i = 0; i < digits.length; i++) {
                maxDigit += digits[i];
            }
            return NumbersFrom(digits, maxDigit);
        }

        static HashSet<Integer> NumbersFrom(int[] digits, int maxDigit) {
            ArrayList<Integer> list = new ArrayList<Integer>();
            for (int i = 0; i < digits.length; i++) {
                if (digits[i] > 0) {
                    list.add(i);
                }
            }
            int t1 = 0;
            int t2 = list.size();
            for (int i = 1; i < maxDigit; i++) {
                for (int j = t1; j < t2; j++) {
                    int number = list.get(j);
                    int temp = number;
                    while (temp > 0) {
                        digits[temp % 10]--;
                        temp /= 10;
                    }

                    for (int k = 0; k < 10; k++) {
                        if (digits[k] > 0) {
                            list.add(number * 10 + k);
                        }
                    }
                    while (number > 0) {
                        digits[number % 10]++;
                        number /= 10;
                    }
                }
                t1 = t2;
                t2 = list.size();
            }
            HashSet<Integer> set = new HashSet<Integer>(list);

            return set;
        }

        static long Exchange(long price, long[] array, boolean remainderAllowed) {
            return Exchange(price, array, true, remainderAllowed);
        }

        static long Exchange(long price, long[] array, boolean sorted, boolean remainderAllowed) {
            if (!sorted) {
                Arrays.sort(array);
            }
            long coins = 0;
            for (int i = array.length - 1; i >= 0 && price > 0; i--) {
                price -= array[i];
                coins++;
            }
            if (remainderAllowed) {
                if (price <= 0) {
                    return coins;
                } else {
                    return 0;
                }
            } else {
                if (price == 0) {
                    return coins;
                } else {
                    return 0;
                }
            }
        }

        static long Exchange(long price, int[] array, boolean remainderAllowed) {
            return Exchange(price, array, true, remainderAllowed);
        }

        static long Exchange(long price, int[] array, boolean sorted, boolean remainderAllowed) {
            if (!sorted) {
                Arrays.sort(array);
            }
            long coins = 0;
            for (int i = array.length - 1; i >= 0 && price > 0; i--) {
                price -= array[i];
                coins++;
            }
            if (remainderAllowed) {
                if (price <= 0) {
                    return coins;
                } else {
                    return 0;
                }
            } else {
                if (price == 0) {
                    return coins;
                } else {
                    return 0;
                }
            }
        }

        static long C(int n, int r) {
            if (r < n / 2) {
                return C(n, n - r);
            }
            return ZarbeMotevali(r + 1, n) / Fact(n - r);
        }

        private static long ZarbeMotevali(int first, int end) {
            long answer = 1;
            for (long i = first; i <= end; i++) {
                answer *= i;
            }
            return answer;
        }

        private static long Fact(int n) {
            return ZarbeMotevali(2, n);
        }

        static int GCD(int m, int n) {
            if (n > m) {
                return GCD(n, m);
            }
            if (m % n == 0) {
                return n;
            }
            return GCD(n, m % n);
        }

        static long GCD(long m, long n) {
            if (n > m) {
                return GCD(n, m);
            }
            if (m % n == 0) {
                return n;
            }
            return GCD(n, m % n);
        }

        static long LCM(long m, long n) {
            return (m * n) / GCD(m, n);
        }

        static int LCM(int m, int n) {
            return (m * n) / GCD(m, n);
        }

        static boolean IsPrime(long a) {
            if (a < 2) {
                return false;
            }
            if (a > 2 && a % 2 == 0) {
                return false;
            }
            long temp = (long) Math.sqrt(a);
            for (long i = 3; i <= temp; i += 2) {
                if (a % i == 0) {
                    return false;
                }
            }
            return true;
        }

        static int BinarySearch(int[] a, int start, int end, int value) {
            if (start == end) {
                return -1; // invalid index
            }
            int mid = (end + start) / 2;
            if (a[mid] == value) {
                return mid;
            }
            if (a[mid] < value) {
                return BinarySearch(a, mid + 1, end, value);
            }
            return BinarySearch(a, start, mid, value);
        }
    }
}

class Graph {

    private int[][] matrix;

    public Graph(int[][] matrix) {
        this.matrix = matrix;
    }

    class MST {

        class Prim {

            private boolean[] Visited;
            //private 
        }
    }

    class DFS {

        private Stack<Integer> DFS;
        private boolean[] visited;

        public DFS() {
            this.DFS = new Stack<Integer>();
            this.visited = new boolean[matrix.length];
        }

        public Stack<Integer> getDFS() {
            this.DFS(0);
            return DFS;
        }

        public Stack<Integer> getDFS(int vertex) {
            this.DFS.clear();
            this.DFS(vertex);
            return this.DFS;
        }

        private void DFS(int vertrx) {
            this.DFS.push(vertrx);
            this.visited[vertrx] = true;

            for (int i = 0; i < matrix[vertrx].length; i++) {
                if (matrix[vertrx][i] != 0 && !this.visited[i] && vertrx != i) {
                    this.DFS(i);
                }
            }
        }
    }
}

class ArithmeticProgression {

    long d;
    long a1;

    public ArithmeticProgression(long a1, long d) {
        this.d = d;
        this.a1 = a1;
    }

    public ArithmeticProgression(long a, long index, long d) {
        this.d = d;
        this.a1 = a - ((index - 1) * d);
    }

    long Term(long n) {
        return this.a1 + ((n - 1) * this.d);
    }

    long S(long n) {
        return S(1, n);
    }

    long S(long m, long n) {
        return ((n - m + 1) * (Term(m) + Term(n))) / 2;
    }
}

class FastScanner {

    private InputStream stream;
    private byte[] buffer = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream) {
        this.stream = stream;
    }

    int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buffer[curChar++];
    }

    boolean isWhiteSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    boolean isEndline(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    float nextFloat() {
        return Float.parseFloat(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String next() {
        int c = read();
        while (isWhiteSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isWhiteSpaceChar(c));
        return res.toString();
    }

    String nextLine() {
        int c = read();
        while (isEndline(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndline(c));
        return res.toString();
    }
}