#include "bits/stdc++.h" using namespace std; vector> solve(int n, vector& a) { vector> res; bool flag = true; for (int i = 0; flag; i++) { flag = false; for (int j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { swap(a[j], a[j - 1]); res.push_back(make_pair(j - 1, j)); flag = true; } } } return res; } int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector> res = solve(n, a); cout << res.size() << endl; for (auto p : res) { cout << p.first << " " << p.second << endl; } cout << flush; return 0; }