module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

void main()
{
    int n;
    readf!"%d\n"(n);

    int[] a;
    a.length = n;

    foreach (ref elem; a)
    {
        readf!" %d"(elem);
    }

    int next = 1;
    int broken = 0;

    foreach (elem; a)
    {
        if (elem != next)
            broken++;
        else
            next++;
    }

    if (broken == n)
        broken = -1;

    writefln("%d", broken);
}
