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.
import copy

n = int(input())
perm = list(map(int, input().split()))
fav = list(map(int, input().split()))

init = []
seed = []
groups = []
p_groups = []
for i in range(n):
    init.append(i)
    seed.append(0)
    perm[i] -= 1


def discover(index):
    if discovered[index] == 1:
        return []
    out_ = [init[index]]
    discovered[index] = 1
    if fav[index]+index < n and index-fav[index] >= 0:
        return out_+discover(index-fav[index])+discover(fav[index]+index)
    if fav[index]+index < n:
        return out_ + discover(fav[index] + index)
    if index-fav[index] >= 0:
        return out_+discover(index-fav[index])
    return out_


def perm_discover(index):
    if p_discovered[index] == 1:
        return []
    out_ = [perm[index]]
    p_discovered[index] = 1
    if fav[index]+index < n and index-fav[index] >= 0:
        return out_+perm_discover(fav[index]+index)+perm_discover(index-fav[index])
    if fav[index]+index < n:
        return out_ + perm_discover(fav[index] + index)
    if index-fav[index] >= 0:
        return out_+perm_discover(index-fav[index])
    return out_


for i in range(n):
    discovered = copy.deepcopy(seed)
    p_discovered = copy.deepcopy(seed)
    groups.append(discover(i))
    p_groups.append(perm_discover(i))

for i in range(n):
    temp = []
    j = 0
    while j < len(groups):
        if i in groups[j]:
            temp += groups[j]
            del groups[j]
            j -= 1
        j += 1
    temp = list(set(temp))
    temp.sort()
    groups.append(temp)

for i in range(n):
    temp = []
    j = 0
    while j < len(p_groups):
        if i in p_groups[j]:
            temp += p_groups[j]
            del p_groups[j]
            j -= 1
        j += 1
    temp = list(set(temp))
    temp.sort()
    p_groups.append(temp)

i = 0
while i < len(groups):
    if len(groups[i]) == 0:
        del groups[i]
        i -= 1
    i += 1

i = 0
while i < len(p_groups):
    if len(p_groups[i]) == 0:
        del p_groups[i]
        i -= 1
    i += 1

if groups == p_groups:
    print("YES")
else:
    print("NO")
