#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  int j = 1;
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    if (a[i] == j)
      j++;
    else
      ans++;
  }
  if (ans != n)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
