using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yuki { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] a = Array.ConvertAll(Console.ReadLine().Split(), delegate(string value) { return int.Parse(value); }); int[] b = Array.ConvertAll(Console.ReadLine().Split(), delegate(string value) { return int.Parse(value); }); int[] p = new int[100]; for (int i = 0; i < p.Length; i++) { p[i] = 0; } int q = 0; //------------------------------------- for (int i = 0; i < b.Length; i++) { if (b[i] == 0) { q += a[i]; } else { p[b[i] - 1] += a[i]; } } if (q >= p.Max()) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } } }