#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; struct P { P( int x, int y ) { a = x; b = y; }; int a; int b; }; int main() { int N; cin >> N; vector A(N); for ( int i = 0; i < N; i++ ) { cin >> A[i]; } vector

V; for ( int i = 0; i < N-1; i++ ) { for ( int j = 0; j < N-1-i; j++ ) { if ( A[j] > A[j+1] ) { swap( A[j], A[j+1] ); P p(j,j+1); V.push_back(p); } } } cout << V.size() << endl; for ( auto& v : V ) { cout << v.a << " " << v.b << endl; } cin >> N; return 0; }