#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
  ll N; cin >> N;
  ll cnt = 1;
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    if(a == cnt) cnt++;
  }
  
  cout << ((cnt != 1)?(N - cnt + 1):(-1)) << endl;
}