#include <bits/stdc++.h>
using namespace std;
#define endl              "\n"
#define pb              push_back
#define fir               first
#define sec               second
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define ll              long long
#define ld              long double
#define lp(i, n)        for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define isPowerOfTwo(s) (!(s & (s-1)))
typedef vector<int> vi;
typedef deque<int> de;
void origi() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
void tiranga() {
    int n, arr[200000], cur = 0, del = 0;
    bool flag = false;
    cin >> n;
    lp(i, n) {
        cin >> arr[i];
        if (arr[i] == 1)
            flag = true;
    }
    if (!flag)
        cout << -1;
    else {
        lp(i, n) {
            if (arr[i] != cur + 1) del++;
            else cur++;
        }
        cout << del;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#else
#endif 
    origi();
    tiranga();
   
}
