from collections import defaultdict


def main():
    N = int(input())
    scores = list(map(int, input().split()))
    solved = list(map(int, input().split()))

    score_estimated = {idx: 0 for idx in range(101)}
    for score, who in zip(scores, solved):
        score_estimated[who] += score

    if score_estimated[0] == max(score_estimated.values()):
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()