package main import ( "fmt" ) func main() { var N int fmt.Scan(&N) a := make([]int, N) b := make([]int, N) c := make([]int, N) for i := 0; i < N; i++ { fmt.Scan(&a[i]) } for i := 0; i < N; i++ { fmt.Scan(&b[i]) } var K int for i := 0; i < N; i++ { if b[i] == 0 { K += a[i] } else { c[b[i]] += a[i] } } for i := 0; i < N; i++ { if K < c[i] { fmt.Println("NO") return } } fmt.Println("YES") }