#include <bits/stdc++.h>

using namespace std;

#define fr first
#define sc second

typedef long long ll;
const ll INF = 100000000007, DIM = 32007, MAXN = 100000;

ll tt, a[DIM], pos[DIM], cnt[DIM], t[DIM], v,u,n,m,res, l, r;
string s;

void solve(){
	cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        pos[a[i]]=i;
    }
    cout<<n<<'\n';
    for(int i=n;i>=1;--i){
        v = min(pos[i], (ll)i);
        u=max(pos[i], (ll)i);
        cout<<v<<" "<<u<<'\n';
    }
    
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	tt=1;
	//cin>>tt;
	while(tt--)
		solve();
	return 0;
}