import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
} import java.io.*; io.* java import java.math.*; math.* java import java.util.*; util.* java public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
} Main static MyScanner in = new MyScanner(); in new MyScanner() static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); out new PrintWriter(new OutputStreamWriter(System.out)) int N; N static int max = 100000; max 100000 static int [] dr = {1,-1,0,0}; dr {1,-1,0,0} 1 -1 1 0 0 static int [] dc={0,0,-1,1}; dc {0,0,-1,1} 0 0 -1 1 1 static int [] Ft = new int  [max+1]; Ft new int  [max+1] max+1 max 1 public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        } main {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        } int N = in.nextInt(); N in.nextInt() in.nextInt in for(int i=0;i<N;i++){
            update(in.nextInt());
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            update(in.nextInt());
        } {
            update(in.nextInt());
        } update(in.nextInt()) update in.nextInt() in.nextInt in int K = 0; K 0 for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        } int i=1; int i=1; i 1 i<=max+1 i max+1 max 1 i++ i++ i {
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        } {
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        } int ABC = prefix(i-1); ABC prefix(i-1) prefix i-1 i 1 int ARC = N-ABC; ARC N-ABC N ABC if(ABC==ARC)
                K++; ABC==ARC ABC ARC K++ K out.println(K) out.println out K out.flush() out.flush out String args[] args static int lsb(int i){return i&-i;} lsb {return i&-i;} return i&-i; i&-i i -i i int i i static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        } prefix {
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        } int sum=0; sum 0 while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            } idx>0 idx 0 {
                sum+=Ft[idx];
                idx-=lsb(idx);
            } sum+=Ft[idx] sum Ft[idx] Ft idx idx-=lsb(idx) idx lsb(idx) lsb idx return sum; sum int idx idx static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        } update {
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        } while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            } idx<=max idx max {
                Ft[idx]+=1;
                idx+=lsb(idx);
            } Ft[idx]+=1 Ft[idx] Ft idx 1 idx+=lsb(idx) idx lsb(idx) lsb idx int idx idx static boolean isEven(long a){
            return (a&1)==0;
        } isEven {
            return (a&1)==0;
        } return (a&1)==0; (a&1)==0 (a&1) a 1 0 long a a static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        } swap {

        int temmp = b;
        b=a;
        a = temmp;
        } int temmp = b; temmp b b=a b a a = temmp a temmp int a a int b b static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        } same {
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        } Arrays.sort(arr) Arrays.sort Arrays arr Arrays.sort(temp) Arrays.sort Arrays temp for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            } int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
                if(temp[i]!=arr[i])
                return false;
            } {
                if(temp[i]!=arr[i])
                return false;
            } if(temp[i]!=arr[i])
                return false; temp[i]!=arr[i] temp[i] temp i arr[i] arr i return false; false return true; true int [] arr arr int [] temp temp public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     } MyScanner BufferedReader br; br StringTokenizer st; st public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        } MyScanner {
           br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        } nextLine {
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        } String str = ""; str "" try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        } catch (IOException e) {
           e.printStackTrace();
        } IOException e {
           e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
           str = br.readLine();
        } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
} public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
} Main
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        for(int i=0;i<N;i++){
            update(in.nextInt());
        }
        int K = 0;
        for(int i=1;i<=max+1;i++){
            int ABC = prefix(i-1);
            int ARC = N-ABC;
            if(ABC==ARC)
                K++;
        }
        out.println(K);
        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}