#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n; cin >> n;
  
  int rmn = 0;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (a == rmn+1) {
      rmn++;
    }
  }

  cout << (rmn ? n - rmn : -1) << endl;

  return 0;
}