import java.io.*; import java.util.*; public class Main_yukicoder74 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int[] d = new int[n]; for (int i = 0; i < n; i++) { d[i] = sc.nextInt(); } int[] w = new int[n]; BitSet[] ma = new BitSet[n + 1]; for (int i = 0; i < n + 1; i++) { ma[i] = new BitSet(n); } for (int i = 0; i < n; i++) { w[i] = sc.nextInt(); if (w[i] == 1) { ma[0].set(i); } } for (int i = 0; i < n; i++) { int tmp = (i + d[i]) % n; ma[i + 1].set(tmp); int tmp2 = ((i - d[i]) % n + n) % n; ma[i + 1].set(tmp2); } int cnt = 0; int p = 1; for (int i = 0; i < n; i++) { boolean flag = false; for (int j = p; j < n + 1; j++) { if (ma[j].get(i)) { flag = true; BitSet tmp = ma[j]; ma[j] = ma[p]; ma[p] = tmp; break; } } if (flag) { cnt++; for (int j = 1; j < n + 1; j++) { if (j != p && ma[j].get(i)) { ma[j].xor(ma[p]); } } if (ma[0].get(i)) { ma[p].clear(); } p++; } else { boolean tmp = false; for (int j = 0; j < p; j++) { tmp ^= ma[j].get(i); } if (tmp) { cnt++; } } } if (cnt == n) { pr.println("Yes"); } else { // pr.println(n); // pr.println(cnt); pr.println("No"); } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { // it = Arrays.asList(br.readLine().split(" ")).iterator(); it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }