#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pl; queue q; int main() { int N; int A[110]; cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } int cnt = 0; for (int i = 1; i < N - 1; i++) { int mx = max(A[i-1],max(A[i],A[i+1])); int mi = min(A[i - 1], min(A[i], A[i + 1])); if (mx == A[i] || mi == A[i]) { cnt++; } } cout << cnt << endl; if (cnt != 0) { for (int j = 0; j < 10; j++) { for (int i = 1; i < N - 1; i++) { int mx = max(A[i - 1], max(A[i], A[i + 1])); int mi = min(A[i - 1], min(A[i], A[i + 1])); if (mx == A[i]) { swap(A[i], A[i + 1]); cout << i << " " << i + 1 << endl; } else if (mi == A[i]) { swap(A[i], A[i - 1]); cout << i << " " << i - 1 << endl; } } } } /* for (int i = 0; i < N; i++) cout << A[i] << " "; cout << endl; */ int damy; cin >> damy; return 0; }