#include <bits/stdc++.h>
#if 1
    #define for_in(x,X) for(auto& x: X)
    #define rep(i,count) for(size_t i=0; i<count; ++i)
    #define for_range(i,begin,end) for(size_t i=begin; i<end; ++i)

    using namespace std;

    typedef unsigned int    uint;
    typedef unsigned char   u8;
    typedef unsigned short  u16;
    typedef unsigned int    u32;
    typedef unsigned long   u64;
    typedef char    s8;
    typedef short   s16;
    typedef int     s32;
    typedef long    s64;
    typedef float   f32;
    typedef double  f64;

    inline char ctoi(char a){return a-'0';}

    template<class T> inline T max(const vector<T> &x){return *max_element(x.begin(), x.end());}
    template<class T> inline T min(const vector<T> &x){return *min_element(x.begin(), x.end());}
    template<class T> inline size_t argmax(const vector<T> &x){auto it = max_element(x.begin(), x.end()); return distance(x.begin(), it);}
    template<class T> inline size_t argmin(const vector<T> &x){auto it = min_element(x.begin(), x.end()); return distance(x.begin(), it);}
    template<class T> inline T sum(const vector<T> &x){return accumulate(x.begin(), x.end(),0);}
    template<class T> inline size_t get_idx(const vector<T> &x, T val){auto it=find(x.begin(),x.end(),val); return distance(x.begin(), it);}
    template<class T> inline bool is_in(T val, const vector<T> &x){auto it=find(x.begin(),x.end(),val); return it!=x.end();}
    template<class T> inline void sort(vector<T> &x){sort(x.begin(), x.end());}
    template<class T, class Compare> inline void sort(vector<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T> inline auto len(const vector<T> &x){return x.size();}
    template<class T> inline ostream& operator<<(ostream& os, const vector<T> &x){os<<'[';for_in(y,x)os<<y<<" ";os<<']'; return os;}

    template<class T> inline T max(const deque<T> &x){return *max_element(x.begin(), x.end());}
    template<class T> inline T min(const deque<T> &x){return *min_element(x.begin(), x.end());}
    template<class T> inline size_t argmax(const deque<T> &x){auto it = max_element(x.begin(), x.end()); return distance(x.begin(), it);}
    template<class T> inline size_t argmin(const deque<T> &x){auto it = min_element(x.begin(), x.end()); return distance(x.begin(), it);}
    template<class T> inline T sum(const deque<T> &x){return accumulate(x.begin(), x.end(),0);}
    template<class T> inline size_t get_idx(const deque<T> &x, T val){auto it=find(x.begin(),x.end(),val); return distance(x.begin(), it);}
    template<class T> inline bool is_in(T val, const deque<T> &x){auto it=find(x.begin(),x.end(),val); return it!=x.end();}
    template<class T> inline void sort(deque<T> &x){sort(x.begin(), x.end());}
    template<class T, class Compare> inline void sort(deque<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T> inline auto len(const deque<T> &x){return x.size();}
    template<class T> inline ostream& operator<<(ostream& os, const deque<T> &x){os<<'[';for_in(y,x)os<<y<<" ";os<<']'; return os;}

    template<class T, size_t SIZE> inline T max(const array<T,SIZE> &x){return *max_element(x.begin(), x.end());}
    template<class T, size_t SIZE> inline T min(const array<T,SIZE> &x){return *min_element(x.begin(), x.end());}
    template<class T, size_t SIZE> inline size_t argmax(const array<T,SIZE> &x){auto it = max_element(x.begin(), x.end()); return distance(x.begin(), it);}
    template<class T, size_t SIZE> inline size_t argmin(const array<T,SIZE> &x){auto it = min_element(x.begin(), x.end()); return distance(x.begin(), it);}
    template<class T, size_t SIZE> inline T sum(const array<T,SIZE> &x){return accumulate(x.begin(), x.end(),0);}
    template<class T, size_t SIZE> inline size_t get_idx(const array<T,SIZE> &x, T val){auto it=find(x.begin(),x.end(),val); return distance(x.begin(), it);}
    template<class T, size_t SIZE> inline bool is_in(T val, const array<T,SIZE> &x){auto it=find(x.begin(),x.end(),val); return it!=x.end();}
    template<class T, size_t SIZE> inline void sort(array<T,SIZE> &x){sort(x.begin(), x.end());}
    template<class T, size_t SIZE, class Compare> inline void sort(array<T,SIZE> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T, size_t SIZE> inline auto len(const array<T,SIZE> &x){return x.size();}
    template<class T, size_t SIZE> inline ostream& operator<<(ostream& os, const array<T,SIZE> &x){os<<'[';for_in(y,x)os<<y<<" ";os<<']'; return os;}

    template<class T> inline T max(const set<T> &x){return *(--x.end());}
    template<class T> inline T min(const set<T> &x){return *(x.begin());}
    template<class T> inline T sum(const set<T> &x){return accumulate(x.begin(), x.end(), 0);}
    template<class T> inline bool is_in(T val, const set<T> &x){return x.count(val);}
    template<class T> inline auto len(const set<T> &x){return x.size();}
    template<class T> ostream& operator<<(ostream& os, const set<T> &x){os<<'{';for_in(y,x)os<<y<<" ";os<<'}'; return os;}

    template<class T> inline T max(const unordered_set<T> &x){return *max_element(x.begin(), x.end());}
    template<class T> inline T min(const unordered_set<T> &x){return *min_element(x.begin(), x.end());}
    template<class T> inline T sum(const unordered_set<T> &x){return accumulate(x.begin(), x.end(), 0);}
    template<class T> inline bool is_in(T val, const unordered_set<T> &x){return x.count(val);}
    template<class T> inline auto len(const unordered_set<T> &x){return x.size();}
    template<class T> ostream& operator<<(ostream& os, const unordered_set<T> &x){os<<'{';for_in(y,x)os<<y<<" ";os<<'}'; return os;}

    template<class T, class U> inline ostream& operator<<(ostream& os, const pair<T,U> &x){os<<x.first<<":"<<x.second; return os;}

    template<class T, class U> inline U max_value(const map<T,U> &x){U _max=(*x.begin()).second; for_in(p,x)_max=max(_max,p.second); return _max;}
    template<class T, class U> inline U min_value(const map<T,U> &x){U _min=(*x.begin()).second; for_in(p,x)_min=min(_min,p.second); return _min;}
    template<class T, class U> inline T max_key(const map<T,U> &x){return (*(--x.end())).first;}
    template<class T, class U> inline T min_key(const map<T,U> &x){return (*(x.begin())).first;}
    template<class T, class U> inline T argmax(const map<T,U> &x){T _argmax=(*x.begin()).first; U _max=(*x.begin()).second; for_in(p,x)if(_max<p.second){_argmax=p.first;_max=p.second;}return _argmax;}
    template<class T, class U> inline T argmin(const map<T,U> &x){T _argmin=(*x.begin()).first; U _min=(*x.begin()).second; for_in(p,x)if(_min>p.second){_argmin=p.first;_min=p.second;}return _argmin;}
    template<class T, class U> inline U sum_value(const map<T,U> &x){U _sum=(*x.begin()).second; for(auto it=++x.begin(); it!=x.end(); ++it) _sum+=(*it).second; return _sum;}
    template<class T, class U> inline T sum_key(const map<T,U> &x){T _sum=(*x.begin()).first; for(auto it=++x.begin(); it!=x.end(); ++it) _sum+=(*it).first; return _sum;}
    template<class T, class U> inline T get_key(const map<T,U> &x, U val){for_in(p,x)if(p.second==val)return p.first;}
    template<class T, class U> inline bool is_in_value(U val, const map<T,U> &x){for_in(p,x)if(p.second==val)return true; return false;}
    template<class T, class U> inline bool is_in_key(T key, const map<T,U> &x){try{x.at(key);}catch(std::out_of_range&){return false;} return true;}
    template<class T, class U> inline auto len(const map<T,U> &x){return x.size();}
    template<class T, class U> inline ostream& operator<<(ostream& os, const map<T,U> &x){os<<'{';for_in(y,x)os<<y<<" ";os<<'}'; return os;}

    template<class T, class U> inline U max_value(const unordered_map<T,U> &x){U _max=(*x.begin()).second; for_in(p,x)_max=max(_max,p.second); return _max;}
    template<class T, class U> inline U min_value(const unordered_map<T,U> &x){U _min=(*x.begin()).second; for_in(p,x)_min=min(_min,p.second); return _min;}
    template<class T, class U> inline T max_key(const unordered_map<T,U> &x){T _max=(*x.begin()).first; for_in(p,x)_max=max(_max,p.first); return _max;}
    template<class T, class U> inline T min_key(const unordered_map<T,U> &x){T _min=(*x.begin()).first; for_in(p,x)_min=min(_min,p.first); return _min;}
    template<class T, class U> inline T argmax(const unordered_map<T,U> &x){T _argmax=(*x.begin()).first; U _max=(*x.begin()).second; for_in(p,x)if(_max<p.second){_argmax=p.first;_max=p.second;}return _argmax;}
    template<class T, class U> inline T argmin(const unordered_map<T,U> &x){T _argmin=(*x.begin()).first; U _min=(*x.begin()).second; for_in(p,x)if(_min>p.second){_argmin=p.first;_min=p.second;}return _argmin;}
    template<class T, class U> inline U sum_value(const unordered_map<T,U> &x){U _sum=(*x.begin()).second; for(auto it=++x.begin(); it!=x.end(); ++it) _sum+=(*it).second; return _sum;}
    template<class T, class U> inline T sum_key(const unordered_map<T,U> &x){T _sum=(*x.begin()).first; for(auto it=++x.begin(); it!=x.end(); ++it) _sum+=(*it).first; return _sum;}
    template<class T, class U> inline T get_key(const unordered_map<T,U> &x, U val){for_in(p,x)if(p.second==val)return p.first;}
    template<class T, class U> inline bool is_in_value(U val, const unordered_map<T,U> &x){for_in(p,x)if(p.second==val)return true; return false;}
    template<class T, class U> inline bool is_in_key(T key, const unordered_map<T,U> &x){try{x.at(key);}catch(std::out_of_range&){return false;} return true;}
    template<class T, class U> inline auto len(const unordered_map<T,U> &x){return x.size();}
    template<class T, class U> inline ostream& operator<<(ostream& os, const unordered_map<T,U> &x){os<<'{';for_in(y,x)os<<y<<" ";os<<'}'; return os;}
#endif

//#include <boost/math/common_factor_rt.hpp>

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    uint N;
    cin>>N;
    uint curr = 1;
    rep(i,N){
        uint num;
        cin>>num;
        if(num==curr)curr++;
    }
    curr--;
    if(curr==0)cout<<-1;
    else cout<<N-curr;
}

Measured memory_bytes: 256