using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
    static class Program_E
    {
        class Solver
        {

            public void Solve()
            {
                var n = Int();
                var a = Ints(0);
                int cnt = 0;
                int index = 1;
                for(int i = 0; i < a.Length;++i)
                {
                    if (a[i] == index)
                    {
                        index++;
                        continue;
                    }
                    cnt++;
                }
                if (cnt == a.Length) Wl("-1");
                else Wl(cnt);

            }





            // ----------------------------------------------------------------------------
            string Rl()
            {
                return Console.ReadLine();
            }
            void Wl(UInt64 val)
            {
                Console.WriteLine(val);
            }
            void Wl(Int64 val)
            {
                Console.WriteLine(val);
            }
            void Wl(uint val)
            {
                Console.WriteLine(val);
            }
            void Wl(int val)
            {
                Console.WriteLine(val);
            }
            void Wl(double val)
            {
                Console.WriteLine(val);
            }
            void Wl(string mes)
            {
                Console.WriteLine(mes);
            }
            public int Int()
            {
                return int.Parse(Console.ReadLine());
            }
            public int[] Ints(int subtract)
            {
                return Console.ReadLine().Split(' ').Select(s => int.Parse(s) - subtract).ToArray();
            }
            public Int64[] Int64s(Int64 subtract)
            {
                return Console.ReadLine().Split(' ').Select(s => Int64.Parse(s) - subtract).ToArray();
            }
            public UInt64[] UInt64s(UInt64 subtract)
            {
                return Console.ReadLine().Split(' ').Select(s => UInt64.Parse(s) - subtract).ToArray();
            }

        }



        static void Main(string[] args)
        {
            new Solver().Solve();
        }
    }
    struct ModInt
    {
        const int MOD = 1000000007;
        long Data;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static implicit operator long(ModInt modInt) => modInt.Data;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static implicit operator ModInt(long val) => new ModInt(val);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ModInt operator +(ModInt a, ModInt b)
        {
            long res = a.Data + b.Data;
            return new ModInt() { Data = res >= MOD ? res - MOD : res };
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ModInt operator +(ModInt a, long b) => a.Data + b;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ModInt operator -(ModInt a, ModInt b)
        {
            long res = a.Data - b.Data;
            return new ModInt() { Data = res < 0 ? res + MOD : res };
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ModInt operator -(ModInt a, long b) => a.Data - b;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % MOD };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static ModInt operator /(ModInt a, ModInt b) => a.Data * GetInverse(b);

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string ToString() => Data.ToString();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static long GetInverse(long a)
        {
            long div;
            long p = MOD;
            long x1 = 1, y1 = 0, x2 = 0, y2 = 1;
            while (true)
            {
                if (p == 1) return x2;
                div = a / p;
                x1 -= x2 * div;
                y1 -= y2 * div;
                a %= p;
                if (a == 1) return x1;
                div = p / a;
                x2 -= x1 * div;
                y2 -= y1 * div;
                p %= a;
            }
        }
    }

}


Measured memory_bytes: 34012