#include<iostream>
using namespace std;
int main()
{
int n,sz=0;
cin>>n;
n++;
int autok[n];
for(int i=1;i<n;i++)
{
cin>>autok[i];
}
for(int i=1;i<n;i++)
{
while(autok[i]!=i)
{
swap(autok[i],autok[autok[i]]);
sz++;
}
}
if(sz<2)cout<<"-1 \n";
else cout<<sz<<'\n
}
open /var/local/lib/isolate/404/box/a.out: no such file or directory
main.cpp:22:20: warning: missing terminating ' character
22 | else cout<<sz<<'\n
| ^
main.cpp:22:20: error: missing terminating ' character
22 | else cout<<sz<<'\n
| ^~~
main.cpp: In function 'int main()':
main.cpp:23:1: error: expected primary-expression before '}' token
23 | }
| ^