import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  foreach (i; 0 .. n) {
    readf (" %d", &a[i]);
  }
  int j;
  foreach (i; 1 .. n + 1) {
    while (j < n && a[j] != i) {
      ++j;
    }
    if (j >= n) {
      int res = n - (i - 1);
      if (res >= n) res = -1;
      writeln (res);
      return;
    }
  }
  writeln (0);
}

