process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line)
});

reader.on('close', () => {

  var d = lines[1].split(' ')
  for (var k in d) d[k] = parseInt(d[k])
  d = d.sort()

  var limit = Math.max(...d)
  var r = 0

  for (var i=0;i<=limit;i++) {
    var s = d.filter(x => x < i)
    if (s.length === d.length - s.length) r++
  }

  console.log(r)

});