#include<iostream>
#include<cmath>
using namespace std;
int N,a,j=1,ans=0;
int main() {
  cin >> N;
  for(int i = 0;i < N;++i){
    cin >> a;
    if(a == j){
      j++;
    }else{
      ans += 1;
    }
  }
  if(j == 1)
    cout << -1;
  else
    cout << ans;
}
