#include<bits/stdc++.h>

using namespace std;

#define endl '\n'
#define DIM 1003
#define INF 1000000009

long long n,res,a[32007],small,curent,j,k;
typedef pair<long long, long long > pll;
pll b[32000];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for(int i =1; i<=n; i++) cin >> a[i];
    j = 0;
    for(int i =1; i<=n-1; i++){
        small = i;
    for(int curent= i+1; curent<=n; curent++){

       if(a[curent]<a[small]){
         small = curent;
       }
     }

         swap(a[i],a[small]); if(a[i]!=a[small]){ j++; b[j].first = a[i]; b[j].second = a[small]; k ++;}
        




    }

    cout << k << endl;
    for(int i =1; i<=k; i++){

        cout << b[i].first << " "<<b[i].second << endl;
    }


}
