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.io.*;
import java.math.BigInteger;
import java.util.*;

public class C implements Runnable {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(null, new C(), "", 128 * (1L << 20)).start();

    }

    void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);

        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();

            init();
            solve();

            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }


    String readString() throws IOException {

        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    String readString(String s) throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), s + "\n \t");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    int readInt(String s) throws IOException {
        return Integer.parseInt(readString(s));
    }
    boolean isPrime(int a) throws IOException {
        int del=0;
        if(a==2){
            return false;
        }
        for(int i=2;i<Math.sqrt(a)+1;i++){
            if(a%i==0){
                del=i;
                break;
            }
        }
        if(del>0){
            return false;
        }
        else return true;
    }


    public BigInteger bigFactorial(int num) throws IOException {
        BigInteger fact = new BigInteger("1");
        BigInteger i = new BigInteger("1");
        BigInteger one = new BigInteger("1");
        for (int j=0;j<num;j++) {
            fact = fact.multiply(i);
            i=i.add(one);
//out.println(fact.toString()+" "+i.toString());
        }
//fact = fact.add(one);

        return fact;
    }

    public long factorial(int num) throws IOException{
        long res=1;
        for(int i=2;i<=num;i++){
            res*=i;
        }
        return res;
    }

    public int[] readIntArr(int n) throws IOException{
        int[] a = new int[n];
        for(int i=0;i<n;i++){
            a[i] = readInt();
        }
        return a;
    }

    public double formatDouble(double d, int dz)
    {
        double dd=Math.pow(10,dz);
        return Math.round(d*dd)/dd;
    }

    public class Pair implements Comparable{
        int a1;
        int a2;

        public int getA1() {
            return a1;
        }

        public int getA2() {
            return a2;
        }

        public void setA1(int a1) {
            this.a1 = a1;
        }

        public void setA2(int a2) {
            this.a2 = a2;
        }

        @Override
        public int compareTo(Object a) {
            Pair b=(Pair) a;
            if(this.a1>((Pair) a).a1){
                return -1;
            }
            if(this.a1==((Pair) a).a1)
                return 0;
            return 1;
        }
    }

    public class Triple implements Comparable{
        int a1;
        int a2;
        int a3;

        public int getA1() {
            return a1;
        }

        public void setA1(int a1) {
            this.a1 = a1;
        }

        public int getA2() {
            return a2;
        }

        public void setA2(int a2) {
            this.a2 = a2;
        }

        public int getA3() {
            return a3;
        }

        public void setA3(int a3) {
            this.a3 = a3;
        }
        @Override
        public int compareTo(Object a) {
            Triple b=(Triple) a;
            if(this.a1>((Triple) a).a1){
                return -1;
            }
            if(this.a1==((Triple) a).a1)
                return 0;
            return 1;
        }
    }

    public static long kth(int l, int r, int k, long[] array) {
        int i = l;
        int j = r;
        long x = array[l + random.nextInt(r - l + 1)];
        while (i <= j) {
            while (array[i] < x) {
                i++;
            }
            while (array[j] > x) {
                j--;
            }
            if (i <= j) {
                long temp = array[i];
                array[i] = array[j];
                array[j] = temp;
                i++;
                j--;
            }
        }
        //1-ый блок
        if (l <= k && k <= j) {
            return kth(l, j, k, array);
        }
        //2-ой блок
        if (i <= k && k <= r) {
            return kth(i, r, k,array);
        }
        //если k во втором блоке, возвращаем непосредственно a[k]
        return array[k];
    }

    public static Random random = new Random();

    int knapsack(int weights[], int like[], int needed) {
        int n = weights.length;
        int dp[][] = new int[needed + 1][n + 1];
        for (int j = 1; j <= n; j++) {
            for (int w = 1; w <= needed; w++) {
                if (weights[j-1] <= w) {
                    dp[w][j] = Math.max(dp[w][j - 1], dp[w - weights[j-1]][j - 1] + like[j-1]);
                } else {
                    dp[w][j] = dp[w][j - 1];
                }
            }
        }
        return dp[needed][n];
    }

    int[] swap(int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
        return a;
    }

    void solve() throws IOException{
        int n=readInt();
        int[] a = readIntArr(n);
        int[] b = new int[n];
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        Arrays.sort(b);
        boolean flag=true;
        ArrayList<String> res= new ArrayList<String>();
        for(int i=0;i<n;i++){
            if(a[i]!=b[i]){
                for(int j=i;j<n;j++){
                    if(a[j]==b[i]){
                        swap(a, i, j);
                        res.add(i+" "+j);
                        break;
                    }
                }
            }
        }
        out.println(res.size());
        for(int i=0;i<res.size();i++){
            out.println(res.get(i));
        }
    }





    public long fn() throws IOException{
        return 0;
    }
    int pow(long x){
        int pow = 0;
        while (x > 0){
            x <<= 1;
            pow++;
        }
        pow--;
        return pow;
    }
}