#include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for(int i=0;i> a[i]; } auto b=a; sort(b.begin(), b.end()); if(a==b){ printf("0\n"); return 0; } while(a.size()){ if(a.back()==b.back()){ a.pop_back(); b.pop_back(); } else break; } n=a.size(); int cnt=0; for(int i=0;ia[(i+1)%n])cnt++; } if(cnt==1){ printf("1\n"); } else{ printf("2\n"); } }