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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.util.*;


public class Soly
{
    static final int INF = Integer.MAX_VALUE;

    static int mergeSort(int[] a,int [] c, int begin, int end)
    {
        int inversion=0;
        if(begin < end)
        {
            inversion=0;
            int mid = (begin + end) >>1;
            inversion+= mergeSort(a,c, begin, mid);
            inversion+=mergeSort(a, c,mid + 1, end);
            inversion+=merge(a,c, begin, mid, end);
        }
        return inversion;
    }
/////////////////////////////////////////////////////

    static int  merge(int[] a,int[]c, int b, int mid, int e)
    {
        int n1 = mid - b + 1;
        int n2 = e - mid;
        int[] L = new int[n1+1], R = new int[n2+1];
        int[] L1 = new int[n1+1], R1 = new int[n2+1];
        //inversion
        int inversion=0;

        for(int i = 0; i < n1; i++) {
            L[i] = a[b + i];
            L1[i] = c[b + i];
        }
        for(int i = 0; i < n2; i++)  {
            R[i] = a[mid + 1 + i];
            R1[i] = c[mid + 1 + i];
        }
        L[n1] = R[n2] = INF;

        for(int k = b, i = 0, j = 0; k <= e; k++)
            if(L[i] <= R[j]){
                a[k] = L[i];
                c[k] = L1[i++];
            }

            else
            {
                a[k] = R[j];
                c[k] = R1[j++];
                inversion=inversion+(n1-i);

            }
        return inversion;

    }
    //////////////////////////////////////////////////////////////
static int l;
 static int va(char[]a){
     Stack<Character>s= new Stack<>();
     int op=0,c=0;
     for (int p = 0; p < a.length; p++) {
         if (a[p]==')'){
             if (!s.isEmpty()){
                 if (s.peek()=='('){
                     op--;
                     s.pop();
                 }
                 else{
                     ++c;
                     s.push(')');
                 }
             }
             else {
                 ++c;
                 s.push(')');
             }
         }
         else if(a[p]=='(') {
             ++op;
             if (!s.isEmpty()){
                 if (s.peek()=='('){
                     s.push(a[p]);
                 }
                 else s.push('(');
             }
             else s.push('(');
         }
     }
     if (s.isEmpty())return 0;
     else {
         if (op>0&&c>0)return 50;
         if (s.peek()=='('){
             //1 opening
             l=s.size();
             return 1;
         }
         else {
             //2 closing
             l=s.size();
             return 2;
         }
     }

 }

/////////////////////////////////////////////////////////////////////////////////
    static public int maxSubArray(int[] nums) {
        boolean s= false,s2=false;
       int ans2=Integer.MIN_VALUE;
        int ans=0,sum=0;
       for (int i = 0; i < nums.length; i++) {
           if (nums[i]>=0)s=true;
           if (nums[i]<0)s2=true;
           ans2=Math.max(ans2,nums[i]);
           if (sum+nums[i]>0)sum+=nums[i];
           else sum=0;
           ans=Math.max(ans,sum);
       }
       if (!s2)return ans;
       if (!s)return ans2;
       else {
           return ans;

       }
   }



    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        try (PrintWriter or = new PrintWriter(System.out)) {
        int n=in.nextInt();
        int [] a= new int[n];
            for (int i = 0; i < n; i++) {
                a[i]=in.nextInt();
            }
            StringBuilder ans= new StringBuilder();
            int sum=0;
            for (int i = 0; i < n-1; i++) {
                    int min=a[i],f=i;
                    for (int j = i+1; j <n ; j++) {
                        if (a[j]<min){
                            min=a[j];
                            f=j;
                        }
                    }
                    if (f!=i){
                        ++sum;
                        int te=a[i];
                        a[i]=a[f];
                        a[f]=te;
                        ans.append(i+" "+f+"\n");
                    }


            }
           
     or.println(sum);
            or.println(ans);



        }
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++) {
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec) {
                        f *= 10;
                    }
                }
            }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }


}
class  Triple{
   int r,c,x,y;
    public Triple(int r, int c, int x, int y) {
        this.r = r;
        this.c = c;
        this.x = x;
        this.y = y;
    }
}