import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format;

long n;
long[] as;

void main(string[] args)
{
    readf("%d\n", &n);
    as = readln.strip.split(" ").to!(long[]);
    as[] -= 1;

    long cur = 0;
    long bad = 0;
    for (long i = 0; i < n; i++)
    {
        if (as[i] == cur)
        {
            cur++;
        }
        else
        {
            as[i] = -1;
            bad++;
        }
    }

    if (bad >= n)
    {
        writeln(-1);
    }
    else
    {
        writeln(bad);
    }
}
