"use strict"

const main = (input) => {
    input = input.split("\n");
    const ds = input[1].split(" ").map(p => Number(p));
    const maxD = ds.reduce((a, b) => a > b ? a : b);

    let ans = 0;
    for (let i = 1; i <= maxD; i++) {
        let arc = 0;
        let abc = 0;
        for (const d of ds) {
            if (i >= d) {
                arc += 1;
            } else {
                abc += 1;
            }
        }
        if (arc == abc) {
            ans += 1;
        }
    }
    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));