#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996) #include #include #include #include #include #include #include using namespace std; #define rep(i,a,b) for(int i=(a);i<(b);i++) #define pb push_back #define mp(a,b) make_pair(a,b) #define all(a) a.begin(),a.end() typedef pair Pii; typedef vector V; typedef long long ll; const int inf = 1e9; const int mod = 1e9 + 7; int N; int A[100] = {}; int cnt = 0; V ans[2]; void quick_sort(int l, int r) { if(l>=r) return; int p = l; int k = l+1; while(k<=r) { if(A[p]>A[k]) { ans[0].pb(p); ans[1].pb(k); cnt++; swap(A[p+1],A[k]); p++; } k++; } swap(A[l],A[p]); quick_sort(l,p-1); quick_sort(p+1,r); return; } int main() { cin >> N; rep(i,0,N) cin >> A[i]; quick_sort(0,N-1); //rep(i,0,N) cout << A[i] << " "; cout << endl; cout << cnt << endl; rep(i,0,cnt) { cout << ans[0][i] << " " << ans[1][i] << endl; } cout << flush; cin >> N; return 0; }