#include #include #include #include #include //#include #include #include //#include #include #include #include //#include #include //#include #include #include #include #include //#include #include //#include #include #include //#include //#include //#include #if __cplusplus >= 201103L #include #include #include #include #include #include #define cauto const auto& #else #endif using namespace std; namespace{ typedef long long ll; typedef pair pii; typedef pair pll; typedef vector vint; typedef vector > vvint; typedef vector vll, vLL; typedef vector > vvll, vvLL; #define VV(T) vector > template void initvv(vector > &v, int a, int b, const T &t = T()){ v.assign(a, vector(b, t)); } template void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep((i),0,(n)) #define ALL(v) (v).begin(),(v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(),(v).rend() #define MOD 1000000007LL #define EPS 1e-8 static const int INF=1<<24; vint used; // vint a(n); vint a; int n; int foo(int x){ if(used[x]){ // bool f=false; rep(i,n){ if(used[i]==0){ return 0; } } return 1; } used[x]=1; int ret=foo(a[x]); used[x]=0; return ret; } void mainmain(){ // int n; cin>>n; a=vint(n); used=vint(n,0); rep(i,n){ cin>>a[i]; a[i]--; } int cnt=0; rep(i,n){ if(i!=a[i]&&a[i]==a[a[a[i]]]){ cnt++; // cout<<"No\n"; // return; } } cout<