'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
inputs.shift();

const heights = inputs.shift().split(' ').map(v => parseInt(v, 10));
const towers = new Array(heights.length).fill().map(function () {
  return [];
});

inputs.forEach(function (v) {
  const splited = v.split(' ').map(function (tmp) {
    return parseInt(tmp, 10) - 1;
  });

  towers[splited[0]].push(splited[1]);
  towers[splited[1]].push(splited[0]);
});

let result = 0;
towers.forEach(function (t, i) {
  let good = true;

  if (t.length) {
    t.forEach(function (t2) {
      if (heights[i] <= heights[t2]) {
        good = false;
      }
    });
  }

  if (good) {
    ++result;
  }
});
console.log(result);