N = int(input()) D = tuple(map(lambda x: int(x) % N, input().split())) W = int(input().replace(" ", ""), 2) D_int = tuple(sum({pow(2, (i + x) % N), pow(2, (i - x) % N)}) for i, x in enumerate(D)) st = {W} for d in D_int: new_st = set() for s in st: new_st.add(s ^ d) st |= new_st print('Yes' if pow(2, N) - 1 in st else 'No')