import itertools N = int(input()) D = list(map(int, input().split(' '))) W_ = list(map(int, input().split(' '))) W = W_ turned = [0]*N def turn(n): if W[n] == 1: W[n] = 0 else: W[n] = 1 def select(n): turn((n+D[n])%N) turn((n-D[n])%N) if ((n+D[n])%N) == ((n-D[n])%N): turn((n+D[n])%N) T = [0,1] for x in itertools.product(T,repeat=N): W = W_ for i in range(0,N): if x[i] == 1: select(i) if 0 not in W: print("YES") exit() print("NO")