let input = require('fs').readFileSync('/dev/stdin', 'utf8');


input = input.split('\n')
  .map(v => v.split(/\s/))
  .map(v => v.map(v => Number(v)));

const sum = arr => arr.length ? arr.reduce((a, b) => a + b) : 0;
const [N, a, b] = input;
let TOTAL = Array(Math.max(...b) + 1).fill(0);
TOTAL = TOTAL.map((v, i) => sum(a.filter((v, j) => b[j] == i)));
console.log(Math.max(...TOTAL) == TOTAL[0] ? 'YES' : 'NO');