One day *n* cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move *i*-th cell can exchange it's value with the value of some other *j*-th cell, if |*i* - *j*| = *d*<sub class="lower-index">*i*</sub>, where *d*<sub class="lower-index">*i*</sub> is a favourite number of *i*-th cell. Cells make moves in any order, the number of moves is unlimited.

The favourite number of each cell will be given to you. You will also be given a permutation of numbers from 1 to *n*. You are to determine whether the game could move to this state.
The first line contains positive integer *n* (1 ≤ *n* ≤ 100) — the number of cells in the array. The second line contains *n* distinct integers from 1 to *n* — permutation. The last line contains *n* integers from 1 to *n* — favourite numbers of the cells.
#!/bin/python3

import math
import os
import random
import re
import sys

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [1] * n
        
    def find(self, x):
        
        while(x != self.parent[x]):
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        
        return x
    
    def union(self, x, y):
        if x < 0 or x >= len(self.parent) or y < 0 or y >= len(self.parent):
            return
        x_p, y_p = self.find(x), self.find(y)
        if x_p == y_p:
            return
        x_rk, y_rk = self.rank[x_p], self.rank[y_p]
        if x_rk > y_rk:
            self.parent[y_p] = x_p
        else:
            self.parent[x_p] = y_p
            if x_rk == y_rk:
                self.rank[y_p] += 1
            return
        
def sort(arr, fav):
    # Write your code here
    n = len(arr)
    uf = UnionFind(n+1)
    for i in range(n):
        uf.union(i+1, i+1+fav[i])
        uf.union(i+1, i+1-fav[i])
    for i in range(n):
        x_p = uf.find(arr[i])
        y_p = uf.find(i+1)
        if x_p != y_p:
            print("NO")
            return False
    print("YES")
    return True
            


if __name__ == '__main__':
    n = int(input())
    arr_str1 = input()
    arr_str2 = input()
    init = [int(x) for x in arr_str1.split(" ")]
    fav = [int(x) for x in arr_str2.split(" ")]
    sort(init, fav)

    


    