
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int Visited[2000009];
int main()
{
    int N , ans=0 , count=0 , cnt=0; 
    cin >> N;
    vector<int>V(N);
    

    for (int j = 0; j < N ; j++)
    {
        cin >> V[j];
    }
    int K = 1;
    for (int j = 0; j < N ; j++)
    {
       
        if (Visited[V[j]] == 0 && V[j]== K)
        {
            Visited[K++] = 1;
        }
        else
        {
            ans++;
        }
    }
    if (ans < N) { cout << ans << endl; }
    else { cout << -1 << endl; }

    return 0;
}