using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] input2 = Console.ReadLine().Split(' ');
            string[] input3 = Console.ReadLine().Split(' ');
            int n = int.Parse(input);
            int[] score = new int[input2.Length];
            int[] answer = new int[input3.Length];
            int[] point = new int[101];
            for(int i=0;i<n;i++)
            {
                score[i] = int.Parse(input2[i]);
                answer[i] = int.Parse(input3[i]);
            }
            for(int i=0;i<100;i++)
            {
                point[i] = 0;
            }
            for (int i = 0; i < n; i++)
            {
                point[answer[i]] = point[answer[i]] + score[i];
            }
            int max = point[0];
            Array.Sort(point);
            Array.Reverse(point);
            if (max >= point[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }

    }
}