#include using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define ll long long const long long mod=998244353; const long long hmod=46216567629137; int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); int N; cin>>N; int P[109]; for(int i=1;i<=N;i++) cin>>P[i]; string ans=""; while(true){ bool check=1; for(int i=1;i<=N;i++){ if(P[i]!=i-1) check=0; } if(check) break; if((P[1]==N-1 && P[2]==0) || P[1]