#include using namespace std; int main(){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector p; for (int i = 0; i < N - 1; i++){ if (A[i] > A[i + 1]){ p.push_back(i); } } if (p.empty()){ cout << 0 << endl; } else if (p.size() == 1){ bool ok = true; for (int i = p[0] + 1; i < N - 1; i++){ if (A[i] > A[p[0]] && A[i + 1] < A[p[0]]){ ok = false; } } if (ok){ cout << 1 << endl; } else { cout << 2 << endl; } } else { cout << 2 << endl; } }