#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n;
scanf("%d", &n);
int pos[n];
int left = 0;
int temp;
for(int i=0; i<n; i++){
scanf("%d", &temp);
pos[temp] = i;
if(pos[temp]!=temp && temp!=0){
left++;
}
}
int k = 1;
int i;
int ans = 0;
while(left > 0){
if(pos[0] == 0){
for(i=k; i<n; i++){
if(pos[i] != i){
swap(pos[i],pos[0]);
ans++;
break;
}
}
k = i;
}else{
swap(pos[0], pos[pos[0]]);
left--;
ans++;
}
}
printf("%d", ans);
return 0;
}
08-16
342