Denis was very sad after Nastya rejected him. So he decided to walk through the gateways to have some fun. And luck smiled at him! When he entered the first courtyard, he met a strange man who was selling something. 

Denis bought a mysterious item and it was... Random permutation generator! Denis could not believed his luck.

When he arrived home, he began to study how his generator works and learned the algorithm. The process of generating a permutation consists of $n$ steps. At the $i$-th step, a place is chosen for the number $i$ $(1 \leq i \leq n)$. The position for the number $i$ is defined as follows:

  For all $j$ from $1$ to $n$, we calculate $r_j$  — the minimum index such that $j \leq r_j \leq n$, and the position $r_j$ is not yet occupied in the permutation. If there are no such positions, then we assume that the value of $r_j$ is not defined.  For all $t$ from $1$ to $n$, we calculate $count_t$  — the number of positions $1 \leq j \leq n$ such that $r_j$ is defined and $r_j = t$.  Consider the positions that are still not occupied by permutation and among those we consider the positions for which the value in the $count$ array is maximum.  The generator selects one of these positions for the number $i$. The generator can choose any position. 

Let's have a look at the operation of the algorithm in the following example:

 [Image] 

Let $n = 5$ and the algorithm has already arranged the numbers $1, 2, 3$ in the permutation. Consider how the generator will choose a position for the number $4$:

  The values of $r$ will be $r = [3, 3, 3, 4, \times]$, where $\times$ means an indefinite value.  Then the $count$ values will be $count = [0, 0, 3, 1, 0]$.  There are only two unoccupied positions in the permutation: $3$ and $4$. The value in the $count$ array for position $3$ is $3$, for position $4$ it is $1$.  The maximum value is reached only for position $3$, so the algorithm will uniquely select this position for number $4$. 

Satisfied with his purchase, Denis went home. For several days without a break, he generated permutations. He believes that he can come up with random permutations no worse than a generator. After that, he wrote out the first permutation that came to mind $p_1, p_2, \ldots, p_n$ and decided to find out if it could be obtained as a result of the generator.

Unfortunately, this task was too difficult for him, and he asked you for help. It is necessary to define whether the written permutation could be obtained using the described algorithm if the generator always selects the position Denis needs.


-----Input-----

The first line contains a single integer $t$ $(1 \leq t \leq 10^5)$  — the number of test cases. Then the descriptions of the test cases follow.

The first line of the test case contains a single integer $n$ $(1 \leq n \leq 10^5)$  — the size of the permutation.

The second line of the test case contains $n$ different integers $p_1, p_2, \ldots, p_n$ ($1 \leq p_i \leq n$)  — the permutation written by Denis.

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$.


-----Output-----

Print "Yes" if this permutation could be obtained as a result of the generator. Otherwise, print "No".

All letters can be displayed in any case.


-----Example-----
Input
5
5
2 3 4 5 1
1
1
3
1 3 2
4
4 2 3 1
5
1 5 2 4 3

Output
Yes
Yes
No
Yes
No



-----Note-----

Let's simulate the operation of the generator in the first test.

At the $1$ step, $r = [1, 2, 3, 4, 5], count = [1, 1, 1, 1, 1]$. The maximum value is reached in any free position, so the generator can choose a random position from $1$ to $5$. In our example, it chose $5$.

At the $2$ step, $r = [1, 2, 3, 4, \times], count = [1, 1, 1, 1, 0]$. The maximum value is reached in positions from $1$ to $4$, so the generator can choose a random position among them. In our example, it chose $1$.

At the $3$ step, $r = [2, 2, 3, 4, \times], count = [0, 2, 1, 1, 0]$. The maximum value is $2$ and is reached only at the $2$ position, so the generator will choose this position.

At the $4$ step, $r = [3, 3, 3, 4, \times], count = [0, 0, 3, 1, 0]$. The maximum value is $3$ and is reached only at the $3$ position, so the generator will choose this position.

At the $5$ step, $r = [4, 4, 4, 4, \times], count = [0, 0, 0, 4, 0]$. The maximum value is $4$ and is reached only at the $4$ position, so the generator will choose this position.

In total, we got a permutation of $2, 3, 4, 5, 1$, that is, a generator could generate it.

Source: codeforces | Difficulty: MEDIUM
Tags: Complete search

Data structures

Implementation

Greedy algorithms


Solutions:
t = int(input())
while t:
	n = int(input())
	p = input().split()
	p = [int(x) for x in p]
	q = [0 for i in range(n)]
	for i in range(n):
		q[p[i] - 1] = i + 1
	flag = True
	prev = q[0]
	for i in range(1, n):
		if q[i] != prev + 1:
			if q[i] > prev:
				flag = False
				break
			prev = q[i]
		else:
			prev = q[i]
	if flag:
		print('Yes')
	else:
		print('No')
	t -= 1


n = int(input())
for i in range(n):
	n = int(input())
	b = list(map(int, input().split()))
	c = dict()
	for j in range(n):
		c[b[j]] = j
	j = 1
	q = n - 1
	p = 1
	f = 0
	while j < n:
		k = c[j]
		if k == q:
			q = c[p] - 1
			p = j + 1
		elif c[j + 1] - k == 1:
			pass
		else:
			f = 1
			break
		j += 1
	if f == 1:
		print('No')
	else:
		print('Yes')


import sys

def check(p):
	visit = [0] * n
	d = {}
	for c in range(n):
		d[p[c]] = c
	for g in range(n):
		if visit[g] == 0:
			num = g + 1
			for h in range(d[num], n):
				if visit[p[h] - 1] == 0:
					if p[h] != num:
						return 'No'
					visit[p[h] - 1] = 1
					num += 1
				else:
					break
	return 'Yes'
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	p = [int(j) for j in sys.stdin.readline().split()]
	print(check(p))


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
for _ in range(t):
	n = int(inp().strip())
	a = [int(x) for x in inp().strip().split()]
	nextNumber = a[-1]
	anyNumber = False
	needToActivate = 1
	firstTime = True
	maxNumber = -1
	for i in range(n - 1, -1, -1):
		maxNumber = max(maxNumber, a[i])
		if a[i] == needToActivate and (firstTime or a[i + 1] == needToActivate + 1 or anyNumber):
			anyNumber = True
			firstTime = False
			needToActivate = maxNumber + 1
		elif a[i] == nextNumber or (a[i] != nextNumber and anyNumber):
			nextNumber = a[i] - 1
			anyNumber = False
		else:
			print('NO')
			break
		firstTime = False
	else:
		print('YES')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	testcases = int(input())
	for j in range(testcases):
		n = int(input())
		perms = list(map(int, input().split()))
		val = True
		for s in range(1, n):
			if perms[s] > perms[s - 1] + 1:
				val = False
				break
		if val == True:
			print('Yes')
		else:
			print('No')
main()


from math import *
for zz in range(int(input())):
	n = int(input())
	p = [int(i) for i in input().split()]
	ind = {}
	for i in range(n):
		ind[p[i]] = i
	used = {n}
	ci = n - 1
	ha = True
	for i in range(1, n + 1):
		if ci + 1 not in used:
			if p[ci + 1] != i:
				ha = False
				break
			ci += 1
		else:
			ci = ind[i]
		used.add(ci)
	if ha:
		print('Yes')
	else:
		print('No')


from collections import Counter
from _collections import defaultdict
import math
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * (n + 1)
	for i in range(0, n):
		d[a[i]] = i + 1
	f = 1
	for i in range(1, n):
		if d[i] < d[i + 1] and d[i] + 1 != d[i + 1]:
			print('No')
			f = 0
			break
	if f:
		print('Yes')


from math import *
from bisect import bisect_left, bisect_right
from queue import Queue
from sys import stdin, stdout
from collections import Counter
input = lambda : stdin.readline().strip()
fast_print = stdout.write
t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	d = {}
	visited = {}
	for i in range(n):
		d[ls[i]] = i
		visited[i] = False
	cur = 1
	flag = 0
	while True:
		start = cur
		if cur == n + 1:
			break
		while True:
			visited[d[cur]] = True
			if cur != start and d[cur] != d[cur - 1] + 1:
				fast_print('No\n')
				flag = 1
				break
			if d[cur] + 1 == n or visited[d[cur] + 1]:
				cur += 1
				break
			cur += 1
		if flag == 1:
			break
	if flag != 1:
		fast_print('Yes\n')


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	A = getInts()
	index = dict()
	reverse_index = dict()
	for j in range(N):
		index[A[j]] = j + 1
		reverse_index[j + 1] = A[j]
	prev_ind = index[1]
	for j in range(2, N + 1):
		if index[j] != prev_ind + 1 and prev_ind + 1 <= N and (reverse_index[prev_ind + 1] > j):
			return 'No'
		prev_ind = index[j]
	return 'Yes'
for _ in range(getInt()):
	ans = solve()
	print(ans)


from collections import Counter
import itertools
from functools import lru_cache
import sys
import math

def helper():
	pass

def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	count = {i: 1 for i in range(1, n + 1)}
	posMap = {arr[i]: i + 1 for i in range(n)}
	maxCount = [1] * n
	filled = set()
	for num in range(1, n + 1):
		pos = posMap[num]
		if pos in filled:
			print('No')
			return
		if count[pos] == maxCount[-1]:
			filled.add(pos)
			if pos + 1 in posMap.keys() and pos + 1 not in filled:
				count[pos + 1] += count[pos]
				if count[pos + 1] > maxCount[-1]:
					maxCount.pop()
					maxCount.append(count[pos + 1])
				elif count[pos + 1] == maxCount[-1]:
					maxCount.append(count[pos + 1])
			if maxCount[-1] == count[pos]:
				maxCount.pop()
			count[pos] = 0
		else:
			print('No')
			return
	print('Yes')
	return
t = int(input())
for _ in range(t):
	solve()


def abc(n, i, l):
	if i == n + 1:
		print(*l)
		return
	r = [0] * n
	c = 0
	for j in range(n - 1, -1, -1):
		if l[j] == -1:
			r[j] = j + 1
			c = j + 1
		else:
			r[j] = c
	d = {}
	for j in range(1, n + 1):
		d[j] = 0
	for j in r:
		if j != 0:
			d[j] += 1
	count = [0] * n
	for j in range(n):
		count[j] = d[j + 1]
	if count == [0] * n:
		for j in range(n):
			l[j] = i
			abc(n, i + 1, l)
			l[j] = -1
	else:
		x = max(count)
		for j in range(n):
			if count[j] == x and l[j] == -1:
				l[j] = i
				abc(n, i + 1, l)
				l[j] = -1
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	c = n
	while i < n:
		x = l[i]
		d = x - 1
		while i < n and l[i] == x:
			i += 1
			x += 1
		if l[i - 1] == c:
			c = d
		else:
			break
	if i == n:
		print('Yes')
	else:
		print('No')


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
mod = 1000000007

def power(x, y):
	res = 1
	while y > 0:
		if y & 1 == 1:
			res = res * x % m
		y = y >> 1
		x = x * x % m
	return res % m
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if l[0] == 1:
		r = sorted(l)
		if l == r:
			print('YES')
		else:
			print('NO')
	else:
		l1 = [l[0]]
		for i in range(n - 1):
			if l[i] - l[i + 1] != -1:
				l1.append(l[i + 1])
		r = sorted(l1)
		r = r[::-1]
		if r == l1:
			print('YES')
		else:
			print('NO')


from math import gcd, sqrt
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	r = 1
	a = False
	for i in range(1, n):
		if l[i] > l[i - 1]:
			if l[i] - l[i - 1] != 1:
				a = True
				break
	if a:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.readline
for t in range(int(input())):
	n = int(input())
	p = list(map(int, input().split(' ')))
	ans = 'Yes'
	allPresent = {}
	for f in range(n):
		allPresent[f + 1] = 0
	allPresent[p[0]] = 1
	for j in range(1, n):
		allPresent[p[j]] = 1
		if p[j] != p[j - 1] + 1:
			if p[j - 1] < p[j]:
				ans = 'No'
	for f in range(n):
		if allPresent[f + 1] == 0:
			ans = 'No'
	print(ans)


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	poss = {}
	for i in range(n):
		poss[arr[i]] = i + 1
	values = {}
	nexts = {}
	prevs = {}
	right = n
	q = []
	checked = [0] * (n + 2)
	checked[0] = 1
	checked[n + 1] = 1
	for i in range(0, n + 2):
		values[i] = 1
		if i == 0:
			nexts[i] = i + 1
		elif i == n + 1:
			prevs[i] = i - 1
		else:
			nexts[i] = i + 1
			prevs[i] = i - 1
		heapq.heappush(q, -1)
	for i in range(1, n + 1):
		pos = poss[i]
		checked[pos] = 1
		if -1 * heapq.heappop(q) == values[pos]:
			prevs[nexts[pos]] = prevs[pos]
			nexts[prevs[pos]] = nexts[pos]
			if checked[nexts[pos]] == 0:
				value = nexts[pos] - prevs[pos]
				values[nexts[pos]] = value
				heapq.heappush(q, -value)
		else:
			print('No')
			break
	else:
		print('Yes')


def solve(arr, n, ans):
	if n <= 2:
		ans.append('Yes')
		return
	indices = [-1] * (n + 1)
	for i in range(n):
		indices[arr[i]] = i
	prev = -1
	x = 1
	while x <= n:
		index = indices[x]
		if index - prev > 1 and prev != -1:
			ans.append('No')
			return
		prev = index
		x += 1
	ans.append('Yes')

def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		solve(arr, n, ans)
	for i in ans:
		print(i)
main()


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	A = getInts()
	for j in range(N - 1):
		if A[j + 1] - A[j] > 1:
			return 'NO'
	return 'Yes'
for _ in range(getInt()):
	ans = solve()
	print(ans)


t = int(input())
for tt in range(t):
	n = int(input())
	p = [int(i) for i in str.split(input(), ' ')]
	indexes = {}
	for i in range(len(p)):
		indexes[p[i]] = i
	i = indexes[1]
	ctr = 1
	valid = True
	while ctr <= n:
		if i == n or p[i] < ctr:
			i = indexes[ctr]
		if p[i] == ctr:
			ctr += 1
			i += 1
		else:
			valid = False
			break
	if valid:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout

def legal(pos, n):
	if pos >= 0 and pos <= n:
		return True
	else:
		return False

def gao(a, n):
	stop = 1
	nxt = a[-1] + 1
	now = nxt - 1
	stop_pos = n - (now - stop)
	if not legal(stop_pos, n):
		return False
	if a[stop_pos] != stop:
		return False
	for pos in reversed(range(1, n + 1)):
		if a[pos] != now:
			return False
		elif a[pos] == now:
			if a[pos] == stop:
				stop = nxt
				nxt = a[pos - 1] + 1
				now = nxt - 1
				if pos == 1:
					return True
				else:
					stop_pos = pos - 1 - (now - stop)
					if not legal(stop_pos, n):
						return False
					if a[stop_pos] != stop:
						return False
			else:
				now = now - 1
			pass
		pass
	pass
	return True
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a = [0] + a
	if gao(a, n):
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	prev = p[0]
	ok = True
	for i in range(1, n):
		if prev + 1 == p[i]:
			pass
		elif prev < p[i]:
			ok = False
			break
		prev = p[i]
	if ok:
		print('Yes')
	else:
		print('No')


for q in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	res = 'Yes'
	for i in range(n - 1):
		if p[i + 1] > p[i] + 1:
			res = 'No'
	print(res)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		arry = list(map(int, input().split()))
		blocks = []
		temp = arry[0]
		ans = True
		for i in range(1, n):
			curr = arry[i]
			prev = arry[i - 1]
			if curr < prev:
				if curr > temp:
					ans = False
					break
				else:
					temp = curr
			elif curr - prev != 1:
				ans = False
				break
		if ans:
			yield 'Yes'
		else:
			yield 'NO'
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())

def solve(left, n, map, arr, block):
	if left >= n:
		return True
	check = map[left]
	initial = map[left]
	while check < block and arr[check] == left:
		left += 1
		check += 1
	if check != block:
		return False
	if left >= n:
		return True
	return solve(left, n, map, arr, initial)
for i in range(t):
	n = int(input())
	arr = []
	list = input().split(' ')
	for j in range(n):
		arr.append(int(list[j]))
	map = {}
	for j in range(n):
		map[arr[j]] = j
	if solve(1, n, map, arr, n):
		print('Yes')
	else:
		print('No')


import sys
import math
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	flag = 'Yes'
	s = set({})
	s.add(a[0])
	for i in range(n - 1):
		s.add(a[i + 1])
		if a[i + 1] > a[i] + 1:
			flag = 'No'
	if not len(s) == n:
		flag = 'No'
	print(flag)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	arr = list(enumerate(p))
	arr.sort(key=lambda x: x[1])
	pos = -1
	d = {}
	for (i, j) in arr:
		i += 1
		if pos != -1:
			if i != pos:
				print('NO')
				break
		if i + 1 > n or d.get(i + 1) != None:
			pos = -1
		else:
			pos = i + 1
		d[i] = 1
	else:
		print('YES')


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	valid = True
	for i in range(1, n):
		if a[i] != a[i - 1] + 1 and a[i] >= a[i - 1]:
			valid = False
	print('Yes' if valid else 'No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))[::-1]
	(cur, nxt) = (1, a[0] + 1)
	flg = True
	for i in range(n - 1):
		if a[i] == cur:
			cur = nxt
			nxt = a[i + 1] + 1
		elif a[i] == a[i + 1] + 1:
			continue
		else:
			flg = False
	print('YES' if flg else 'NO')


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
ans = []
for _ in range(ii()):
	n = ii()
	d = li()
	pos = [0] * (n + 1)
	for i in range(n):
		pos[d[i]] = i
	(c, j) = (1, n)
	while c < n + 1:
		if not all((d[i] == d[i - 1] + 1 for i in range(pos[c] + 1, j))):
			break
		(j, c) = (pos[c], c + j - pos[c])
	ans.append('Yes' if c == n + 1 else 'No')
prr(ans, '\n')


(_int, _range) = (int, range)
from sys import stdout, stdin
(_input, _print) = (stdin.buffer.readline, stdout.write)

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		arr = [_int(i) for i in _input().split()]
		for i in _range(n):
			if i == 0:
				classifier = arr[i]
			elif arr[i] - arr[i - 1] != 1:
				if arr[i] > classifier:
					print('No')
					break
				classifier = arr[i]
		else:
			print('Yes')
solution()


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	ans = 'Yes'
	for i in range(len(array) - 1):
		if array[i + 1] > array[i] + 1:
			ans = 'No'
			break
	print(ans)


t = int(input())
for testcase in range(t):
	n = int(input())
	poof = list(map(int, input().split(' ')))
	p = [0 for _ in range(n)]
	pis = [-1 for _ in range(n + 1)]
	for i in range(n):
		pis[poof[i]] = i
	lastIndex = -1
	end = n - 1
	newEnd = -1
	bad = False
	for j in range(0, n):
		if lastIndex != -1:
			if pis[j] != lastIndex + 1:
				bad = True
				break
		else:
			newEnd = pis[j] - 1
		lastIndex = pis[j]
		if lastIndex == end:
			lastIndex = -1
			end = newEnd
	if bad:
		print('No')
	else:
		print('Yes')


def solve():
	n = int(input())
	li = [int(x) for x in input().split()]
	for i in range(n - 1):
		if li[i + 1] > li[i]:
			if li[i + 1] - li[i] != 1:
				print('NO')
				break
	else:
		print('YES')
t = int(input())
for i in range(t):
	solve()


t = int(input())
while t > 0:
	N = int(input())
	a = list(map(int, input().split()))
	k = 0
	while k < N - 1:
		if a[k + 1] < a[k]:
			k += 1
		elif a[k + 1] == a[k] + 1:
			k += 1
		else:
			break
	if k == N - 1:
		print('Yes')
	else:
		print('No')
	t -= 1


t = int(input())
for a in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	remaining = [True for i in range(n)]
	current = 0
	possible = True
	while current < n:
		current += 1
		index = nums.index(current)
		remaining[index] = False
		while current <= n and index < n - 1 and (remaining[index + 1] == True):
			if current + 1 == nums[index + 1]:
				current += 1
				index += 1
			else:
				possible = False
				break
		if not possible:
			break
	if possible:
		print('YES')
	else:
		print('NO')


from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	d = {}
	done = [0] * (n + 1)
	end = n
	for i in range(n):
		d[arr[i]] = i + 1
	poss = 1
	def_nxt = 0
	for i in range(1, n + 1):
		pos = d[i]
		if not def_nxt:
			def_nxt = 1
			next = pos + 1
			while next == n + 1 or done[next]:
				next -= 1
				def_nxt = 0
			if not done[pos]:
				done[pos] = 1
			else:
				poss = 0
				break
		elif pos == next:
			next = pos + 1
			while next == n + 1 or done[next]:
				next -= 1
				def_nxt = 0
		else:
			poss = 0
			break
	if poss:
		print('Yes')
	else:
		print('No')


from math import factorial as fac
from collections import defaultdict
from copy import deepcopy
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
sys.setrecursionlimit(10 ** 6)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m
from collections import deque, defaultdict
import heapq

def bfs(V, E):
	s = set()
	print('\n'.join(map(str, E.items())))
	cnt = 0
	for v in V:
		if v in s:
			continue
		q = deque([])
		s.add(v)
		q.append(v)
		while len(q) > 0:
			x = q.popleft()
			for e in E[x]:
				if e not in s:
					s.add(e)
					q.append(e)
			print(q)
		cnt += 1
	return cnt
from typing import List, Tuple

def regular_bs(L, x, l=None, r=None):
	l = 0 if l == None else l
	r = len(L) if r == None else r
	while r - l > 1:
		m = (r + l) // 2
		l = m if L[m] <= x else l
		r = m if L[m] > x else r
	cnt = 0
	return l

def binary_count_smaller(L, x):
	l = 0
	if x < L[0]:
		return 0
	r = len(L)
	while r - l > 1:
		mid = (l + r) // 2
		if L[mid] < x:
			l = mid
		else:
			r = mid
	return l + 1

def binary_count_larger(L, x):
	l = 0
	if x > L[-1]:
		return 0
	r = len(L)
	while r - l > 1:
		mid = (l + r) // 2
		if L[mid] <= x:
			l = mid
		else:
			r = mid
	return len(L) - (r - 1)

def solution(A, n):
	i = 0
	cur_min = max(A) + 1
	while i < n:
		if A[i] > cur_min:
			return 'No'
		cur_min = A[i]
		while i < n - 1 and A[i] == A[i + 1] - 1:
			i += 1
		i += 1
	return 'Yes'

def main():
	T = read_int()
	for i in range(T):
		n = read_int()
		A = read_int_array()
		print(solution(A, n))
main()


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cases = int(input())
for t in range(cases):
	n = int(input())
	p = list(map(int, input().split()))
	out = 'Yes'
	for i in range(n - 1):
		if p[i + 1] > p[i] + 1:
			out = 'No'
			break
	print(out)


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def get_left_ps(a):
	left_ps = []
	for i in range(len(a) - 1, 0, -1):
		if a[i] < a[i - 1]:
			left_ps.append(i)
	return left_ps

def get_idxs(a):
	sorted_range = list(range(len(a)))
	idxs = sorted(zip(sorted_range, a), key=lambda pair: pair[1])
	indexes = [item[0] for item in idxs]
	return indexes

def solve(a):
	if len(a) == 1:
		return 'YES'
	p = get_idxs(a)
	left_ps = get_left_ps(a)
	k = 0
	for i in range(1, len(a)):
		if p[i] != 0:
			if a[p[i] - 1] == a[p[i]] - 1:
				None
			elif p[i] < left_ps[k]:
				k += 1
			else:
				return 'NO'
	return 'YES'
answers = []
t = int(input())
for i in range(t):
	n = int(input())
	a = to_list(input())
	answers.append(solve(a))
print('\n'.join(answers))


def solve(n, p):
	i = 1
	while n:
		for j in range(n):
			if p[j] == i:
				break
		else:
			return 'No'
		for k in range(j + 1, n):
			if p[k] != i + k - j:
				return 'No'
		i += n - j
		n = j
	return 'Yes'
for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	print(solve(n, p))


import sys, math, cmath, time
start_time = time.time()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def solve():
	n = inp()
	a = inlt()
	q = [0] * len(a)
	for i in range(len(a)):
		q[a[i] - 1] = 1
		if not (a[i] == n or (q[a[i]] == 0 and a[i + 1] - a[i] == 1) or q[a[i]] == 1):
			break
	if q.count(1) == len(a):
		print('Yes')
	else:
		print('No')
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
t = inp()
for tt in range(t):
	solve()
if not ONLINE_JUDGE:
	print('Time Elapsed:', time.time() - start_time, 'seconds')
sys.stdout.close()


import sys
from operator import ge

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

class SegTree:

	def __init__(self, n, func, intv, A=[]):
		self.n = n
		self.func = func
		self.intv = intv
		n2 = 1
		while n2 < n:
			n2 <<= 1
		self.n2 = n2
		self.tree = [self.intv] * (n2 << 1)
		if A:
			for i in range(n):
				self.tree[n2 + i] = A[i]
			for i in range(n2 - 1, -1, -1):
				self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def update(self, i, x):
		i += self.n2
		self.tree[i] = x
		while i > 0:
			i >>= 1
			self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def add(self, i, x):
		self.update(i, self.get(i) + x)

	def query(self, a, b):
		l = a + self.n2
		r = b + self.n2
		s = self.intv
		while l < r:
			if r & 1:
				r -= 1
				s = self.func(s, self.tree[r])
			if l & 1:
				s = self.func(s, self.tree[l])
				l += 1
			l >>= 1
			r >>= 1
		return s

	def get(self, i):
		return self.tree[i + self.n2]

	def all(self):
		return self.tree[1]

	def print(self):
		for i in range(self.n):
			print(self.get(i), end=' ')
		print()

	def bisect_left(self, l, r, x, op):
		ok = r
		ng = l - 1
		while ng + 1 < ok:
			mid = (ok + ng) // 2
			if op(self.query(l, mid + 1), x):
				ok = mid
			else:
				ng = mid
		return ok

def bisearch_min(mn, mx, func):
	ok = mx
	ng = mn
	while ng + 1 < ok:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok
for _ in range(INT()):
	N = INT()
	P = [(p, i) for (i, p) in enumerate(LIST())]
	P.sort()
	C = SegTree(N, max, 0, [1] * N)
	for (p, idx) in P:
		if C.all() != C.get(idx):
			No()
			break
		res = C.bisect_left(idx + 1, N, 1, ge)
		if res < N:
			if C.get(res) != 0:
				C.add(res, C.get(idx))
		C.update(idx, 0)
	else:
		Yes()


kl = int(input())
for l in range(kl):
	n = int(input())
	pk = n + 1
	pr = 0
	for i in input().split():
		if pr:
			continue
		i = int(i)
		if i > pk and i != pk + 1:
			pr = 1
		pk = i
	if pr:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	reva = [0] * N
	for i in range(N):
		reva[a[i] - 1] = i
	ng = 0
	for x in reva:
		for i in range(x, N - 1):
			if a[i] == 0 or a[i + 1] == 0:
				a[i] = 0
				break
			if a[i + 1] != a[i] + 1:
				ng = 1
				break
			a[i] = 0
		a[-1] = 0
		if ng:
			break
	if ng:
		print('No')
	else:
		print('Yes')


t = int(input())
for q in range(t):
	n = int(input())
	mass = [int(x) for x in input().split()]
	d = dict()
	for i in range(n):
		d[mass[i]] = i + 1
	ch = n
	ind = 0
	answer = 'Yes'
	last = n
	while ch > 0:
		if ind == 0:
			ind = d[n - ch + 1]
			if ind == last:
				ind = 0
				last -= 1
			ch -= 1
		else:
			ind += 1
			ch -= 1
			if ind > last:
				last = ch
				ind = 0
				continue
			if mass[ind - 2] + 1 != mass[ind - 1]:
				answer = 'No'
				break
	print(answer)


T = int(input())
for t in range(T):
	N = int(input())
	P = [int(i) for i in input().split()]
	greatest_seen_number = 0
	target_number = 1
	just_found_target = True
	for R in range(len(P) - 1, -1, -1):
		greatest_seen_number = max(greatest_seen_number, P[R])
		if not just_found_target and P[R] != P[R + 1] - 1:
			print('No')
			break
		just_found_target = False
		if P[R] == target_number:
			target_number = greatest_seen_number + 1
			just_found_target = True
	else:
		print('Yes')


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(i) for i in input().split()]
	count = [0 for i in range(len(arr))]
	r = [-1 for i in range(len(arr))]
	bool = True
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] == 1:
			pass
		elif arr[i - 1] > arr[i]:
			pass
		else:
			bool = False
			break
	if bool:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	for i in range(n - 1):
		if a[i + 1] < a[i]:
			i += 1
		elif a[i + 1] == a[i] + 1:
			i += 1
		else:
			break
	if i == n - 1:
		print('Yes')
	else:
		print('No')


for T in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count = [1] * n
	d = {}
	last = n - 1
	res = 'Yes'
	if n == 1:
		if arr[0] == 1:
			print('Yes')
		else:
			print('No')
	else:
		for i in range(n):
			d[arr[i]] = i
		visited = [False] * n
		for i in range(1, n):
			ind = d[i]
			visited[ind] = True
			if ind != last:
				if d[i + 1] == ind + 1 or visited[ind + 1] == True:
					continue
				else:
					res = 'No'
					break
			last = min(last, d[i] - 1)
		print(res)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n):
	for i in range(1, n):
		if arr[i] - arr[i - 1] > 1:
			write('NO')
			return
	write('YES')

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(arr, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import os
import sys
from io import BytesIO, IOBase

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	T = iin()
	for _ in range(T):
		n = iin()
		a = lin()
		d1 = {a[i]: i for i in range(n)}
		done = {}
		ls = n
		ans = 'No'
		for i in range(1, n + 1):
			pos = d1[i]
			if i in done:
				if pos != done[i]:
					break
			else:
				j = i
				while pos < ls:
					done[j] = pos
					pos += 1
					j += 1
				ls = d1[i]
		else:
			ans = 'Yes'
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	s = 'Yes'
	k = 1
	d = {}
	for i in range(n):
		d[l[i]] = i
	c = n
	while k < n + 1:
		c1 = d[k]
		for i in range(c1, c):
			if l[i] != k:
				s = 'No'
				break
			k += 1
		if s == 'No':
			break
		else:
			c = c1
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	a = [0] * (n + 1)
	for j in range(n):
		a[p[j]] = j
	b = [0] * n
	ind = n
	flag = True
	for j in range(n):
		if ind == n or b[ind] == 1:
			ind = a[j + 1]
		elif p[ind] != j + 1:
			flag = False
			break
		b[ind] = 1
		ind += 1
	if flag:
		print('Yes')
	else:
		print('No')


from math import *
from collections import *
from operator import itemgetter
import bisect
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
chrIdx = lambda x: ord(x) - 96
idxChr = lambda x: chr(96 + x)
t = ii()
for _ in range(t):
	n = ii()
	a = iia()
	d = dict()
	r = [0 for i in range(n)]
	c = [0 for i in range(n)]
	f = [0 for i in range(n)]
	for i in range(n):
		d[a[i]] = i
	flag = 'Yes'
	i = 1
	while i < n:
		if i + 1 <= n and (d[i] > d[i + 1] or d[i] + 1 == d[i + 1]):
			flag = 'Yes'
		else:
			flag = 'No'
			break
		i += 1
	print(flag)


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def ok(aa, n):
	if min(aa) != 1:
		return False
	if max(aa) != n:
		return False
	if max(Counter(aa).values()) > 1:
		return False
	l = aa[0]
	pa = aa[0]
	for a in aa[1:]:
		if a > pa + 1:
			return False
		if a < pa:
			if l < a:
				return False
			l = a
		pa = a
	return True

def main():
	for _ in range(II()):
		n = II()
		aa = LI()
		if ok(aa, n):
			print('Yes')
		else:
			print('No')
main()


T = int(input())
for test in range(T):
	N = int(input())
	goal = list(map(int, input().split()))
	verdict = 'Yes'
	index = 1
	while index < N:
		if goal[index] > goal[index - 1] + 1:
			verdict = 'No'
			break
		index += 1
	print(verdict)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	dic = {}
	for j in range(n):
		dic[l[j]] = j
	flag = 0
	for j in range(1, n):
		if dic[j] > dic[j + 1] or dic[j + 1] - dic[j] == 1:
			flag = 0
		else:
			flag = 1
			break
	if flag == 0:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	flag = True
	for i in range(n - 1):
		if l[i + 1] < l[i] or l[i] + 1 == l[i + 1]:
			continue
		flag = False
		break
	if flag:
		print('Yes')
	else:
		print('No')


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	n = read_int()
	a = list(read_ints())
	d = dict()
	for i in range(n):
		d[a[i]] = i
	ok = True
	num = 1
	pos = d[num]
	left = n - 1
	used = [False for i in range(n)]
	used[pos] = True
	while num < n:
		num += 1
		pos += 1
		if pos >= n or used[pos]:
			pos = d[num]
		if a[pos] != num:
			ok = False
			break
		used[pos] = True
	print('Yes' if ok else 'No')


numcases = int(input())

def isPossible(arr, n):
	p1 = arr[0]
	p2 = 0
	count = 0
	for i in range(n - 1):
		if arr[i + 1] - arr[i] == 1:
			continue
		elif arr[i + 1] < arr[i]:
			count = count + 1
			if count > 1:
				if p1 - arr[i] == 1:
					p1 = p2
					p2 = arr[i + 1]
					continue
				else:
					return 'No'
			else:
				p2 = arr[i + 1]
		else:
			return 'No'
	return 'Yes'
for i in range(numcases):
	n = int(input())
	arr = list(map(int, input().split()))
	print(isPossible(arr, n))


for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	print('YNeos'[any((y - x > 1 for (x, y) in zip(a, a[1:])))::2])


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def outln(var):
	sys.stdout.write(str(var) + '\n')

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	arr = l()
	index = dd(int)
	for i in range(n):
		index[arr[i]] = i + 1
	(i, result, last) = (1, True, n)
	while i <= n and result:
		if index[i] == last:
			last -= 1
		else:
			(temp, j) = (index[i], i)
			while temp < last:
				if index[j + 1] == index[j] + 1:
					j += 1
				else:
					result = False
					break
				temp = index[j]
			last = index[i] - 1
			i = j
		i += 1
	if result:
		outln('Yes')
		continue
	outln('No')


t = int(input())
for test in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	delta = [0] * (n + 1)
	delta[0] = 1
	s = p[0]
	flag = 0
	delta[s] = 1
	for i in range(1, n):
		if p[i] == s + 1:
			delta[p[i]] = 1
			s += 1
			continue
		elif s == n:
			s = p[i]
			delta[s] = 1
		elif delta[s + 1] == 1:
			s = p[i]
			delta[s] = 1
		else:
			flag = 1
			break
	if flag == 0:
		print('Yes')
	else:
		print('No')


import math
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
yes = lambda : print('YES')
no = lambda : print('NO')
I = lambda : list(input())
J = lambda x: ''.join(x)
II = lambda : int(input())
SI = lambda : input()
t = II()
for q in range(t):
	n = II()
	p = LI()
	a = [0] * (n + 1)
	lastTem = n - 1
	lastItem = 1
	ans = True
	for i in range(n):
		a[p[i]] = i
	for i in range(2, n + 1):
		if a[i] - 1 != a[i - 1]:
			if a[i - 1] != lastTem:
				ans = False
				break
			else:
				aa = lastTem
				lastTem = a[lastItem] - 1
				lastItem = p[aa] + 1
	if ans == True:
		print('Yes')
	else:
		print('No')


t = int(input())
for test in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	value_position = {}
	for i in range(len(p)):
		value_position[p[i]] = i + 1
	value_position_list = []
	for i in range(len(p)):
		value_position_list.append(value_position[i + 1])
	current_max = n
	need_to_check = 0
	flag = 0
	for i in range(len(value_position_list)):
		current_value = value_position_list[i]
		if need_to_check == 1:
			if current_value != next_expected_value:
				print('No')
				flag = 1
				break
		if need_to_check == 0:
			current_start = current_value
		if current_value == current_max:
			current_max = current_start - 1
			need_to_check = 0
		else:
			need_to_check = 1
			next_expected_value = current_value + 1
	if flag == 0:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	temp = []
	cur = [s[0]]
	for i in range(1, n):
		if s[i] < s[i - 1]:
			temp.append(cur)
			cur = [s[i]]
		else:
			cur.append(s[i])
	temp.append(cur)
	temp.reverse()
	ans = []
	for i in temp:
		ans += i
	if ans == [i for i in range(1, n + 1)]:
		print('Yes')
	else:
		print('No')


t = int(input())
for br in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	q = sorted(a)
	max_k = a[n - 1]
	F = True
	for i in range(n - 1, 0, -1):
		if a[i - 1] == a[i] - 1 or a[i - 1] > max_k:
			max_k = max(max_k, a[i])
		else:
			F = False
	if F:
		print('Yes')
	else:
		print('No')


from sys import stdin
input = stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	temp = {}
	for i in range(n):
		temp[a[i]] = i
	cur = 1
	fl = 1
	while 1:
		idx = temp[cur]
		for i in range(idx, n):
			if a[i] != cur + i - idx:
				fl = -1
				break
		if fl == -1:
			break
		if idx == 0:
			break
		cur = a[n - 1] + 1
		n = idx
	if fl == -1:
		print('No')
	else:
		print('Yes')


T = int(input())
for case in range(T):
	N = int(input())
	data = list(map(int, input().split()))
	position = [None] * N
	for (i, elt) in enumerate(data):
		position[elt - 1] = i + 1
	base = position[0]
	before = position[0]
	toreach = N
	correct = 'Yes'
	for elt in position[1:]:
		if before == toreach:
			toreach = base - 1
			base = elt
		elif elt != before + 1:
			correct = 'No'
			break
		before = elt
	print(correct)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(el) for el in input().split()]
	pos = [0 for i in range(n)]
	for i in range(n):
		a[i] -= 1
		pos[a[i]] = i
	r = n
	l = pos[0]
	k = 0
	it = 0
	prev = -1
	bad = False
	while not bad and k < n:
		l = pos[k]
		it = l
		while not bad and it < r:
			k += 1
			if a[it] == prev + 1:
				prev = a[it]
				it += 1
			else:
				print('No')
				bad = True
				break
		r = l
	if not bad:
		print('Yes')


for t in range(int(input())):
	num = int(input())
	lis = list(map(int, input().split()))
	bar = []
	ch = []
	for king in range(3):
		ch.append(king)
	for k in range(num + 1):
		bar.append(0)
	for i in range(num):
		bar[lis[i]] = i + 1
	emilia = 0
	for i in range(1, num):
		if bar[i] > bar[i + 1] or bar[i + 1] - bar[i] == 1:
			emilia = 0
		else:
			emilia = 1
			break
	if emilia == 0:
		print('Yes')
	else:
		print('No')


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	ans = 'YES'
	for i in range(n - 1):
		if l[i] < l[i + 1]:
			if l[i + 1] != l[i] + 1:
				ans = 'NO'
				continue
	print(ans)


import heapq
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	for i in range(n):
		b[a[i] - 1] = i
	c = [1] * n
	r = [-1] * n
	heapq.heapify(r)
	fl = 0
	for i in range(n):
		x = heapq.heappop(r)
		if c[b[i]] == -x:
			if b[i] != n - 1:
				c[b[i] + 1] += 1
				heapq.heappush(r, -c[b[i] + 1])
			c[b[i]] = -1
		else:
			fl = 1
			break
	if fl:
		print('No')
	else:
		print('Yes')


MOD = 10 ** 9 + 7

def main():
	for _ in inputt():
		(n,) = inputi()
		A = inputl()
		m = n
		pre = 0
		for a in A:
			if pre:
				if a != pre + 1:
					print('No')
					break
			else:
				n = m
				m = a - 1
			pre = a
			if a == n:
				pre = 0
		else:
			print('Yes')
from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(1000)
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	sys.stdout.write(kwargs.pop('split', ' ').join(map(str, args)))
	sys.stdout.write(kwargs.pop('end', '\n'))
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip()
inputt = lambda t=0: range(t) if t else range(int(input()))
inputs = lambda : input().split()
inputi = lambda : map(int, inputs())
inputl = lambda t=0, k=inputi: map(list, (k() for _ in range(t))) if t else list(k())

def len(a):
	if isinstance(a, range):
		return -((a.start - a.stop) // a.step)
	return builtins.len(a)

def bisect_left(a, x, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	while lo < hi:
		mid = (lo + hi) // 2
		if key(a[mid]) < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def bisect_right(a, x, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	while lo < hi:
		mid = (lo + hi) // 2
		if x < key(a[mid]):
			hi = mid
		else:
			lo = mid + 1
	return lo

def insort_left(a, x, key=None, lo=0, hi=None):
	lo = bisect_left(a, x, key, lo, hi)
	a.insert(lo, x)

def insort_right(a, x, key=None, lo=0, hi=None):
	lo = bisect_right(a, x, key, lo, hi)
	a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right

def index(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	i = bisect_left(a, x, key, lo, hi)
	if lo <= i < hi and key(a[i]) == x:
		return a[i]
	if default != None:
		return default
	raise ValueError

def find_lt(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_left(a, x, key, lo, hi)
	if lo < i <= hi:
		return a[i - 1]
	if default != None:
		return default
	raise ValueError

def find_le(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_right(a, x, key, lo, hi)
	if lo < i <= hi:
		return a[i - 1]
	if default != None:
		return default
	raise ValueError

def find_gt(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_right(a, x, key, lo, hi)
	if lo <= i < hi:
		return a[i]
	if default != None:
		return default
	raise ValueError

def find_ge(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_left(a, x, key, lo, hi)
	if lo <= i < hi:
		return a[i]
	if default != None:
		return default
	raise ValueError

class Tree:

	def __init__(n):
		self._n = n
		self._conn = [[] for _ in range(n)]
		self._list = [0] * n

	def connect(a, b):
		pass

class Sieve:

	def __init__(self):
		self._n = 6
		self._list = [2, 3, 5, 7, 11, 13]

	def extend(self, n):
		pass
sieve = Sieve()

def isprime(n):
	pass

def prime(n):
	pass

def factorint(n):
	factordict = defaultdict(int)
	for i in sieve:
		if n <= i * i:
			break
		while not n % i:
			factordict[i] += 1
			n //= i
	if n != 1:
		factordict[n] += 1
	return factordict
main()


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	d = {val: ind for (ind, val) in enumerate(arr)}
	i = 1
	arr1 = [-1] * n
	while i != n + 1:
		x = d[i]
		if arr1[x] != -1:
			break
		arr1[x] = i
		i += 1
		for j in range(x + 1, n):
			if arr1[j] != -1:
				break
			arr1[j] = i
			i += 1
	if arr == arr1:
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	b = X[0]
	R = []
	tmp = [b]
	for x in X[1:]:
		if b == x - 1:
			tmp.append(x)
		else:
			R.append(tmp)
			tmp = [x]
		b = x
	R.append(tmp)
	b = 0
	f = 1
	for r in R[::-1]:
		for x in r:
			if x != b + 1:
				f = 0
			b = x
	if f:
		print('YES')
	else:
		print('NO')


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	result = True
	curval = dat[0]
	used = [False] * (n + 1)
	used[curval] = True
	for i in range(1, n):
		if used[dat[i]]:
			result = False
			break
		used[dat[i]] = True
		if dat[i] == curval + 1:
			curval += 1
			continue
		if dat[i] < curval:
			curval = dat[i]
			continue
		result = False
		break
	print('Yes' if result else 'No')


from sys import stdin, stdout
import heapq as hq
from collections import defaultdict
t = int(input())
for tc in range(t):
	n = int(stdin.readline())
	ar = list(map(int, stdin.readline().split()))
	cur = ar[0]
	limit = ar[0]
	res = 'Yes'
	for value in ar:
		if value != cur + 1 and value > limit:
			res = 'No'
			break
		cur = value
		if cur < limit:
			limit = cur
	stdout.write(str(res) + '\n')


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) - 1 for a in input().split()]
	D = {a: i for (i, a) in enumerate(A)}
	X = [0] * N + [1]
	pre = N - 1
	for k in range(N):
		i = D[k]
		if X[pre + 1] or i == pre + 1:
			pre = i
			X[pre] = 1
		else:
			print('No')
			break
	else:
		print('Yes')


import heapq as hq

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		nums = list(map(int, input().split()))
		dic = {nums[i]: i + 1 for i in range(n)}
		last = n + 1
		cur = 1
		flag = True
		while cur <= n and flag:
			if dic[cur] > last:
				flag = False
				break
			tmp = dic[cur]
			for i in range(dic[cur], last):
				if nums[i - 1] != cur:
					flag = False
					break
				cur += 1
			last = tmp
		if flag:
			print('Yes')
		else:
			print('No')
main()


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	pos = [0] * (n + 5)
	for i in range(0, len(s)):
		pos[s[i]] = i + 1
	c = 0
	ans = 'Yes'
	kk = [0] * (n + 5)
	kk[n + 1] = 1
	for i in range(1, n + 1):
		if c == 0:
			if kk[pos[i]] == 1:
				ans = 'No'
				break
			else:
				kk[pos[i]] = 1
				if kk[pos[i] + 1] == 0:
					ptr = pos[i] + 1
					c = 1
		elif c == 1:
			if pos[i] != ptr:
				ans = 'No'
				break
			elif kk[pos[i]] == 1:
				ans = 'No'
				break
			else:
				kk[pos[i]] = 1
				if kk[pos[i] + 1] == 0:
					ptr = pos[i] + 1
					c = 1
				else:
					c = 0
	print(ans)


def solve(a, d):
	n = len(a)
	i = n - 1
	while i >= 0 and a[i] == d:
		i -= 1
		d += 1
	if i > 0:
		num = d
		c = a[0:i + 1]
		gind = c.index(num)
		flag = True
		for j in range(gind + 1, len(c)):
			if c[j] != c[j - 1] + 1:
				flag = False
				break
		if flag:
			return solve(c[:gind], c[-1] + 1)
		else:
			return False
	else:
		return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().strip().split()]
	flag = solve(a, 1)
	if flag:
		print('Yes')
	else:
		print('No')


class inp:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def ilist():
		return list(map(int, input().split()))

	@staticmethod
	def imap():
		return map(int, input().split())

	@staticmethod
	def list():
		return input().split()

	@staticmethod
	def str():
		return list(input())

def main():
	t = inp.int()
	for _ in range(t):
		n = inp.int()
		p = inp.ilist()[::-1]
		current_min = 1
		prev = p[0] + 1
		changed = False
		ma = p[0]
		for pi in p:
			if not changed and prev - pi != 1:
				print('No')
				break
			if changed:
				ma = pi
				changed = False
			if pi == current_min:
				current_min = ma + 1
				changed = True
			prev = pi
		else:
			print('Yes')
main()


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
res = ['Yes', 'No']
t_c = ii()
while t_c:
	t_c -= 1
	n = ii()
	a = li()
	cnt = [1] * n + [0]
	pos = [-1] * (n + 1)
	mx = 1
	f = 0
	for i in range(n):
		pos[a[i]] = i
	for i in range(1, n + 1):
		if cnt[pos[i]] != mx:
			f = 1
			break
		if not cnt[pos[i] + 1]:
			mx = 1
		else:
			cnt[pos[i] + 1] += cnt[pos[i]]
			mx += 1
		cnt[pos[i]] = 0
	print(res[f])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	temp = {}
	for i in range(n):
		temp[a[i]] = i
	cur = 1
	fl = 1
	while 1:
		idx = temp[cur]
		for i in range(idx, n):
			if a[i] != cur + i - idx:
				fl = -1
				break
		if fl == -1:
			break
		if idx == 0:
			break
		cur = a[n - 1] + 1
		n = idx
	if fl == -1:
		print('No')
	else:
		print('Yes')


from sys import stdin, stdout
q = int(input())
for i in range(q):
	n = int(input())
	p = list(map(int, stdin.readline().split()))
	visited = [0 for i in range(n)]
	index = [0 for i in range(n)]
	for i in range(n):
		index[p[i] - 1] = i
	k = 1
	i = 0
	flag = 0
	while k != n:
		ind = index[k - 1]
		while visited[k - 1] != 1 or visited[ind] != 1:
			if visited[p[ind] - 1] == 1:
				break
			if p[ind] != k:
				flag = 1
				break
			visited[k - 1] = 1
			k = k + 1
			ind = ind + 1
			if ind > n - 1 or k >= n:
				break
		if flag == 1:
			break
	if flag == 1:
		print('No')
	else:
		print('Yes')


t = int(input())
for i10 in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	d = [0] * n
	for i in range(n):
		d[a[i] - 1] = i
	l = -1
	f1 = True
	for i in range(n - 1):
		if l == -1:
			b[d[i]] = i + 1
			if d[i] + 1 != n:
				l = d[i] + 1
				f = False
				if b[l] == 0:
					f = True
				while l < n and b[l] != 0:
					if b[l] == 0:
						f = True
						break
					l += 1
				if f == False or b[l] != 0:
					l = -1
		elif d[i] != l:
			print('No')
			f1 = False
			break
		else:
			b[d[i]] = i + 1
			if d[i] + 1 != n:
				l = d[i] + 1
				f = False
				if b[l] == 0:
					f = True
				while l < n and b[l] != 0:
					if b[l] == 0:
						f = True
						break
					l += 1
				if f == False or b[l] != 0:
					l = -1
		if l != -1 and b[l] != 0:
			l = -1
	if f1 == True:
		print('Yes')


import heapq
T = int(input())
for t in range(T):
	n = int(input().strip())
	vals = list(map(int, input().strip().split(' ')))
	inv = [-1 for _ in range(n)]
	for i in range(n):
		inv[vals[i] - 1] = i
	removed = set()
	max_count = -1
	imposs = False
	for step in range(n):
		if max_count == -1 or max_count == inv[step]:
			removed.add(inv[step])
			if inv[step] + 1 < n and inv[step] + 1 not in removed:
				max_count = inv[step] + 1
			else:
				max_count = -1
		else:
			imposs = True
			break
	if imposs:
		print('No')
	else:
		print('Yes')


t = int(input())

def sol():
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if a[i] + 1 != a[i + 1] and a[i] < a[i + 1]:
			return False
	return True
for i in range(t):
	print('Yes' if sol() else 'No')


from sys import stdin, exit
import bisect
input = stdin.readline

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	n = ii()
	p = liis()
	P = [[i, idx] for (idx, i) in enumerate(p)]
	P = sorted(P)
	used = [0 for i in range(n)]
	numbers = set()
	can = True
	last = n
	for j in P:
		i = j[0]
		idx = j[1]
		for k in range(idx, last):
			last = idx
			if k == idx:
				if used[k]:
					can = False
					break
				used[k] = 1
			elif used[k] or p[k] != p[k - 1] + 1:
				can = False
				break
			used[k] = 1
	if can:
		print('Yes')
	else:
		print('No')


from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
sqrt = math.sqrt

def LI():
	return list(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def LI_():
	return list(map(lambda x: int(x) - 1, input().split()))

def II():
	return int(input())

def IF():
	return float(input())

def S():
	return input().rstrip()

def LS():
	return S().split()

def IR(n):
	return [II() for _ in range(n)]

def LIR(n):
	return [LI() for _ in range(n)]

def FR(n):
	return [IF() for _ in range(n)]

def LFR(n):
	return [LI() for _ in range(n)]

def LIR_(n):
	return [LI_() for _ in range(n)]

def SR(n):
	return [S() for _ in range(n)]

def LSR(n):
	return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

def solve():
	n = II()
	a = LI()
	i = 0
	while i < n - 1:
		if a[i] < a[i + 1]:
			if a[i] + 1 == a[i + 1]:
				i += 1
				continue
			print('No')
			return
		i += 1
	print('Yes')
	return
for _ in range(II()):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	count = 0
	for index in range(1, n):
		if nums[index] > nums[index - 1]:
			if nums[index] - nums[index - 1] != 1:
				count += 1
	if count == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 'Yes'
	for i in range(n - 1):
		if arr[i + 1] > arr[i] + 1:
			ans = 'No'
	print(ans)


import collections
import itertools
from functools import reduce
mod = 10 ** 9 + 7

def permutationbysum():
	for _ in range(int(input())):
		(num, l, r, achieve) = map(int, input().split())
		k = r - l + 1
		if k * (k + 1) // 2 <= achieve <= k * (num * 2 + 1 - k) // 2:
			outpos = r % num
			inpos = l - 1
			ans = [0] * num
			for i in range(num, 0, -1):
				if achieve - i > 0 or (achieve - i == 0 and inpos == r - 1):
					achieve -= i
					ans[inpos] = i
					inpos += 1
				else:
					ans[outpos] = i
					outpos += 1
					outpos %= num
			print(*ans)
		else:
			print(-1)

def peaks():
	for _ in range(int(input())):
		(num, peak) = map(int, input().split())
		pos = 1
		rpos = num
		ans = []
		now = 0
		if num == 1:
			if not peak:
				print(1)
			else:
				print(-1)
			continue
		if num == 2:
			if peak:
				print(-1)
			else:
				print(1, 2)
			continue
		added = 0
		while rpos + 1 != pos:
			if not peak:
				while pos <= rpos:
					ans.append(pos)
					pos += 1
				break
			if not now:
				ans.append(pos)
				pos += 1
			else:
				ans.append(rpos)
				rpos -= 1
				if num - added != 1:
					peak -= 1
			added += 1
			now = 1 - now
		if peak:
			print(-1)
			continue
		print(*ans)
import sys
input = sys.stdin.readline

def addone():
	for _ in range(int(input())):
		(num, changes) = input().split()
		l = collections.deque(sorted([int(i) for i in num]))
		perm = collections.deque()
		changes = int(changes)
		cd = 0
		ans = len(num)
		while True:
			nextnum = l.pop()
			while perm and perm[-1] == nextnum:
				l.append(perm.pop())
			c = 10 - nextnum - cd
			changes -= c
			cd += c
			if changes >= 0:
				if not c:
					perm.appendleft(1 - cd)
					l.appendleft(-cd)
				else:
					l.appendleft(1 - cd)
					l.appendleft(-cd)
				ans += 1
			else:
				break
		print(ans % 1000000007)
import math

def andsequences():

	def mapping(num):
		nonlocal mnum
		nonlocal c
		num = int(num)
		if num < mnum:
			mnum = num
			c = 1
		elif num == mnum:
			c += 1
		return num
	mod = 1000000007
	for _ in range(int(input())):
		mnum = float('inf')
		c = 0
		num = int(input())
		l = list(map(mapping, input().split()))
		for i in l:
			if mnum & i != mnum:
				print(0)
				break
		else:
			if c == 1:
				print(0)
			else:
				print(math.factorial(num - 2) * (c - 1) * c % mod)

def numberdigit():
	n = 10 ** 5 * 2
	l = [0] * 11
	mod = 10 ** 9 + 7
	l[0] = l[1] = l[2] = l[3] = l[4] = l[5] = l[6] = l[7] = l[8] = 2
	l[9] = 3
	l[10] = 4
	for i in range(11, n):
		l.append((l[i - 10] + l[i - 9]) % mod)
	for _ in range(int(input())):
		(num, c) = input().split()
		c = int(c)
		ans = 0
		for i in num:
			i = int(i)
			if 10 - i > c:
				ans += 1
			else:
				ans += l[c - (10 - i)]
		print(ans % mod)

def mushroom():
	(people, t1, t2, percent) = map(int, input().split())
	l = []
	percent = 1 - percent * 0.01
	for i in range(1, people + 1):
		(s, s1) = map(int, input().split())
		l.append([i, max(s * t1 * percent + s1 * t2, s1 * t1 * percent + s * t2)])
	l.sort(key=lambda x: x[1], reverse=True)
	for i in l:
		i[1] = '{:.2f}'.format(i[1])
		print(*i)

def escape():
	prins = int(input())
	dra = int(input())
	start = int(input())
	pack = int(input())
	c = int(input())
	speeddiff = dra - prins
	if speeddiff <= 0:
		return 0
	pd = start * prins
	ans = 0
	while pd < c:
		hs = pd / speeddiff
		pd += prins * hs
		if pd >= c:
			break
		time = pd / dra
		time += pack
		pd += prins * time
		ans += 1
	return ans

def perm():

	def high(n, k):
		return k * (2 * n - k + 1) // 2

	def low(k):
		return k * (k + 1) // 2
	for _ in range(int(input())):
		(num, lef, rig, s) = map(int, input().split())
		k = rig - lef + 1
		(rig, lef) = (rig - 1, lef - 1)
		if not high(num, k) >= s >= low(k):
			print(-1)
			continue
		l = [0] * num
		lp = lef
		rp = lef - 1
		for i in range(num, 0, -1):
			if high(i, k) >= s and s - i >= low(k - 1) and k:
				l[lp] = i
				lp += 1
				s -= i
				k -= 1
			else:
				l[rp] = i
				rp -= 1
		if k:
			print(-1)
		else:
			print(*l)

def newcom():
	for _ in range(int(input())):
		(days, price) = map(int, input().split())
		dl = input().split()
		worth = input().split()
		worth.append(0)
		ans = float('inf')
		req = 0
		left = 0
		for i in range(days):
			a = int(dl[i])
			w = int(worth[i])
			ans = min(ans, req + max(0, price - left + a - 1) // a)
			ns = max(0, w - left + a - 1) // a
			req += ns + 1
			left += a * ns - w
		print(ans)

def perfectsq():
	for _ in range(int(input())):
		n = input()
		for i in input().split():
			sq = math.sqrt(int(i))
			if sq != int(sq):
				print('YES')
				break
		else:
			print('NO')

def and0big():
	for _ in range(int(input())):
		(l, k) = map(int, input().split())
		print(l ** k % mod)
import math

def mod1p():
	n = int(input())
	ans = dict()
	p = 1
	for i in range(1, n):
		if math.gcd(i, n) == 1:
			ans[str(i)] = True
			p = p * i % n
	if p == 1:
		print(len(ans))
		print(' '.join(ans.keys()))
	else:
		ans.pop(str(p))
		print(len(ans))
		print(' '.join(ans.keys()))

def shorttask():
	num = 10000100
	l = [-1] * (num + 2)
	s = [-1] * (num + 2)
	l[1] = 1
	for i in range(2, int(math.sqrt(num + 1)) + 2):
		if l[i] == -1:
			l[i] = i
			for x in range(i * i, num + 1, i):
				if l[x] == -1:
					l[x] = i
	s[1] = 1
	for i in range(2, num + 1):
		if l[i] == -1:
			l[i] = i
			s[i] = i + 1
		else:
			i1 = i
			s[i] = 1
			while i1 % l[i] == 0:
				i1 //= l[i]
				s[i] = s[i] * l[i] + 1
			s[i] *= s[i1]
	ans = [-1] * (num + 1)
	for i in range(num, 0, -1):
		if s[i] < num:
			ans[s[i]] = i
	for _ in range(int(input())):
		print(ans[int(input())])

def review():
	for _ in range(int(input())):
		n = int(input())
		ans = 0
		for i in input().split():
			i = int(i)
			if i == 1 or i == 3:
				ans += 1
		print(ans)

def GCDleng():
	po10 = [0] * 11
	po10[1] = 1
	for i in range(2, 11):
		po10[i] = po10[i - 1] * 10
	for _ in range(int(input())):
		(n, n1, res) = map(int, input().split())
		print(po10[n], po10[n1] + po10[res])

def anothercarddeck():
	(n, q) = map(int, input().split())
	l = input().split()
	d = {l[i]: i for i in range(n - 1, -1, -1)}
	ans = []
	for i in input().split():
		now = d[i]
		ans.append(now + 1)
		for key in d:
			if d[key] < now:
				d[key] += 1
		d[i] = 0
	print(*ans)

def mincoststring():
	(n, letters) = map(int, input().split())
	l = [chr(i + 97) for i in range(letters)]
	ans = []
	real = letters - 1
	if not n:
		print(*ans, sep='')
		return
	if n == 1:
		print(*ans, sep='', end='')
		print(l[1 % (real + 1)])
		return
	while n:
		for i in range(len(l)):
			for i1 in range(i, len(l)):
				if i1 != real:
					ans.append(l[i1])
					ans.append(l[i])
					n -= 2
				else:
					ans.append(l[i1])
					n -= 1
				if not n:
					print(*ans, sep='')
					return
				if n == 1:
					print(*ans, sep='', end='')
					print(l[(i1 + 1) % (real + 1)])
					return
	print(*ans)

def mincost2():
	(n, letters) = map(int, input().split())
	l = [chr(i + 97) for i in range(letters)]
	comb = []
	if letters == 1 or n == 1:
		print('a' * n)
		return
	for i in range(letters):
		for i1 in range(i, letters):
			comb.append(l[i1] + l[i])
	lc = len(comb)
	while True:
		for i in range(lc):
			if ord(comb[i][0]) - 97 == letters - 1:
				n -= 1
				print(comb[i][0], end='')
			else:
				n -= 2
				print(comb[i], end='')
			if n == 1:
				pos = ord(comb[i][0]) - 97 + 1
				print(l[pos % letters])
				return
			if not n:
				return

def Tittat():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		for i in range(n):
			if not k:
				break
			while k and l[i]:
				l[i] -= 1
				l[-1] += 1
				k -= 1
		print(*l)

def xorq2():
	for _ in range(int(input())):
		n = int(input())
		s = 0
		num = -1
		nc = 0
		c = 0
		for i in input().split():
			i = int(i)
			s ^= i
			c += 1
			if num == -1 and s == i:
				num = s
				s = 0
				nc += c
				c = 0
			if num != -1 and (s == num or not s):
				s = 0
				nc += c
				c = 0
		print(['NO', 'YES'][nc == n])

def xorq2re():
	n = int(input())
	s = input().split()
	xor = 0
	for i in range(n):
		s[i] = int(s[i])
		xor ^= s[i]
	if not xor:
		print('YES')
	else:
		new = 0
		ans = 0
		for i in s:
			new ^= i
			if new == xor:
				new = 0
				ans += 1
		print(['NO', 'YES'][ans > 1])
import sys
sys.setrecursionlimit(2300)

def q3partition():

	def partition():
		if tol % 2:
			return 0
		up = tol
		rec = [[False] * (up + 2) for _ in range(n + 1)]
		rec[0][0] = True
		for i in range(1, n + 1):
			v = l[i - 1]
			for j in range(up + 1):
				if rec[i - 1][j]:
					if v + j <= up:
						rec[i][j + v] = True
					rec[i][j] = True
		return rec[n][tol // 2]

	def ints(x):
		nonlocal tol
		nonlocal gcf
		x = int(x)
		tol += x
		gcf = math.gcd(gcf, x) if gcf != float('inf') else x
		return x
	n = int(input())
	tol = 0
	gcf = float('inf')
	l = list(map(ints, input().split()))
	if partition():
		pos = 1
		for i in l:
			if i // gcf % 2:
				print(1)
				print(pos)
				return
			pos += 1
	else:
		print(0)

def permu(n, r):
	return math.factorial(n) // math.factorial(n - r)

def comb(n, r):
	return math.factorial(n) // math.factorial(r) * math.factorial(n - r)

def calc():
	n = int(input())
	ans = permu(n, n)
	for i in range(1, n + 1):
		ans -= comb(n, i)
	print(ans)

def order():
	for _ in range(int(input())):
		n = int(input())
		odd = []
		even = []
		for i in input().split():
			i = int(i)
			if i % 2:
				odd.append(i)
			else:
				even.append(i)
		print(*odd + even)

def TMTdoc():
	n = int(input())
	l = input().rstrip()
	tts = 0
	tms = 0
	for i in l:
		if i == 'T':
			tts += 1
		else:
			tms += 1
	if tms * 2 == tts:
		nowts = 0
		nowms = 0
		for i in l:
			if i == 'T':
				nowts += 1
			else:
				nowms += 1
				if nowts >= nowms and tms - nowms + 1 <= tts - nowts:
					continue
				return 'NO'
	else:
		return 'NO'
	return 'YES'

def relayrace():

	def solve(n):
		if n:
			s = -1
		else:
			s = 1
		nowmax = -float('inf')
		nowmin = -nowmax
		ans = 0
		for (i, v) in sorted(l, key=lambda x: (x[1], s * int(x[0])), reverse=True):
			i = int(i)
			if i > nowmax:
				nowmax = i
			if i < nowmin:
				nowmin = i
			ans += v * (nowmax - nowmin)
		return ans
	n = int(input())
	l = -1
	ans = 0
	for i in sorted(input().split(), key=lambda x: int(x)):
		if l == -1:
			l = int(i)
		else:
			ans += int(i) - l
	return ans

def relayraces():
	n = int(input())
	l = sorted(map(int, input().split()))
	minv = float('INF')
	minpos = 0
	for i in range(len(l)):
		if i > 0 and 0 <= l[i] - l[i - 1] <= minv:
			minv = l[i] - l[i - 1]
			minpos = i
		if i < n - 1 and l[i + 1] - l[i] <= minv:
			minv = l[i + 1] - l[i]
			minpos = i
	lpos = minpos - 1
	rpos = minpos + 1
	ans = 0
	while lpos >= 0 and rpos < n:
		diffl = -(l[lpos] - l[minpos])
		diffr = l[rpos] - l[minpos]
		if diffl < diffr:
			minpos = lpos
			lpos -= 1
			ans += diffl
		else:
			minpos = rpos
			rpos += 1
			ans += diffr
	if lpos < 0:
		m = l[0]
		for i in range(rpos, n):
			ans += l[i] - m
	else:
		h = l[-1]
		for i in range(minpos, -1, -1):
			ans += h - l[i]
	return ans

def relayracess():

	def recur(l, r):
		if l == r:
			return 0
		if d[l, r] != -1:
			return d[l, r]
		ans = nums[r] - nums[l] + min(recur(l + 1, r), recur(l, r - 1))
		d[l, r] = ans
		return ans
	d = collections.defaultdict(lambda : -1)
	n = int(input())
	nums = sorted(map(int, input().split()))
	return recur(0, n - 1)

def relayracesss():
	n = int(input())
	l = sorted(map(int, input().split()))
	dp = [[0] * n for _ in range(n)]
	for i in range(n - 2, -1, -1):
		for i1 in range(i + 1, n):
			dp[i][i1] = l[i1] - l[i] + min(dp[i + 1][i1], dp[i][i1 - 1])
	return dp[0][n - 1]

def relayracessss():
	n = int(input())
	l = sorted(map(int, input().split()))
	dp = [0] * n
	for le in range(n - 2, -1, -1):
		for ri in range(le + 1, n):
			dp[ri] = l[ri] - l[le] + min(dp[ri], dp[ri - 1])
	return dp[-1]

def binli():
	n = int(input())
	n2 = n * 2
	s = input().rstrip()
	s1 = input().rstrip()
	s2 = input().rstrip()
	posl = [0, 0, 0]
	ans = ''
	while max(posl) < n2:
		l = [[], []]
		l[int(s[posl[0]])].append(0)
		l[int(s1[posl[1]])].append(1)
		l[int(s2[posl[2]])].append(2)
		if len(l[0]) >= 2:
			for i in l[0]:
				posl[i] += 1
			ans += '0'
		else:
			for i in l[1]:
				posl[i] += 1
			ans += '1'
	if posl[0] == n2:
		if posl[1] >= posl[2]:
			ans += s1[posl[1]:]
		else:
			ans += s2[posl[2]:]
	elif posl[1] == n2:
		if posl[0] >= posl[2]:
			ans += s[posl[0]:]
		else:
			ans += s2[posl[2]:]
	elif posl[0] >= posl[1]:
		ans += s[posl[0]:]
	else:
		ans += s1[posl[1]:]
	print(ans)

def almostsort():
	(n, k) = map(int, input().split())
	ul = 2 ** (n - 1)
	if k > ul:
		return [-1]
	permen = []
	bi = bin(k - 1)[2:]
	if bi == '0':
		return range(1, n + 1)
	pos = n - len(bi)
	ans = list(range(1, pos))
	for i in bi:
		permen.append(pos)
		if not int(i):
			ans += permen[::-1]
			permen = []
		pos += 1
	permen.append(n)
	ans += permen[::-1]
	return ans

def q1_2050():
	for i in range(int(input())):
		s = int(input())
		if s % 2050:
			print(-1)
		else:
			ab = 2050
			while ab <= s:
				ab *= 10
			ab //= 10
			c = 0
			while s and s != 1:
				c += s // ab
				s = s % ab
				while s != 1 and s and (s < ab):
					ab //= 10
			print(c)

def q2jog():
	(n, m) = map(int, input().split())
	sortbyval = []
	rowsv = [collections.defaultdict(int) for _ in range(n)]
	for row in range(n):
		for i in input().split():
			i = int(i)
			sortbyval.append([i, row])
			rowsv[row][i] += 1
	sortbyval.sort(key=lambda x: x[0])
	larl = []
	for i in range(0, n * m, m):
		larl.append(sortbyval[i:i + m])
	ans = [[0] * m for _ in range(n)]
	person = 0
	for i in larl:
		for (v, pos) in i:
			ans[pos][person] = v
			rowsv[pos][v] -= 1
			person += 1
			if person == m:
				break
		else:
			continue
		break
	for r in range(n):
		for c in range(m):
			if not ans[r][c]:
				for key in list(rowsv[r].keys()):
					if not rowsv[r][key]:
						rowsv[r].pop(key)
						continue
					rowsv[r][key] -= 1
					ans[r][c] = key
					break
	for i in ans:
		print(*i)

def q3fillomino(n, inp):

	def gorow():
		nonlocal nowp
		nonlocal col
		nonlocal totake
		t = 0
		if nowp and col < n and totake and (not l[col][nowp - 1]):
			for back in range(nowp, -1, -1):
				if l[col][back]:
					nowp += 1
					col += 1
					return t
				if not totake:
					return t
				l[col][back] = i
				totake -= 1
				nowp -= 1
				t = 1
			nowp += 1
			col += 1
		return t
	l = [[0] * i for i in range(1, n + 1)]
	p = 0
	for i in inp:
		totake = int(i)
		nowp = p
		col = p
		while col < n:
			if not totake:
				break
			for _ in range(n - p):
				if not gorow():
					break
			if not totake or col == n or nowp == n:
				break
			l[col][nowp] = i
			totake -= 1
			col += 1
		p += 1
	for i in l:
		print(*i)

def q3fillominoclear(n, inp):
	l = [[0] * i for i in range(1, n + 1)]
	p = 0
	for i in inp:
		take = int(i) - 1
		l[p][p] = i
		(x, y) = (p, p)
		while take:
			if y and (not l[x][y - 1]):
				y -= 1
			else:
				x += 1
			l[x][y] = i
			take -= 1
		p += 1
	for i in l:
		print(*i)

def q4explor():

	def gen(r, c):
		res = float('inf')
		if r:
			res = min(res, his[r - 1][c] + 2 * colstep[r - 1][c])
		if r < rows - 1:
			res = min(res, his[r + 1][c] + 2 * colstep[r][c])
		if c:
			res = min(res, his[r][c - 1] + 2 * rowstep[r][c - 1])
		if c < cols - 1:
			res = min(res, his[r][c + 1] + 2 * rowstep[r][c])
		return res
	(rows, cols, k) = map(int, input().split())
	if k % 2:
		for i in range(rows):
			print(*[-1] * cols)
		return
	rowstep = [list(map(int, input().split())) for _ in range(rows)]
	colstep = [list(map(int, input().split())) for _ in range(rows - 1)]
	his = [[0] * cols for _ in range(rows)]
	for _ in range(k // 2):
		temp = [[gen(r, c) for c in range(cols)] for r in range(rows)]
		his = temp
	for i in his:
		print(*i)

def cvacations():

	def de(v):
		nonlocal last
		if v == 2:
			last = 2
		elif v == 1:
			last = 1
	n = int(input())
	ans = 0
	last = 0
	l = input().split()
	for i1 in range(n):
		i = int(l[i1])
		if not i:
			last = 0
			ans += 1
			continue
		if i == 1:
			if last != 2:
				last = 2
				continue
			ans += 1
			last = 0
		elif i == 2:
			if last != 1:
				last = 1
				continue
			ans += 1
			last = 0
		elif not last:
			if i1 < n - 1:
				de(int(l[i1 + 1]))
				if int(l[i1 + 1]) == 3:
					for pos in range(i1 + 2, n):
						if l[pos] != 3:
							r = l[pos]
							break
					else:
						last = 1
						continue
					de(r)
			else:
				break
		elif last == 1:
			last = 2
		elif last == 2:
			last = 1
	return ans

def brackets():
	s = input().rstrip()
	(lpos, rpos) = (0, len(s) - 1)
	ans = []
	while lpos + 1 <= rpos:
		if s[lpos] == '(':
			if s[rpos] == ')':
				ans.append(lpos + 1)
				ans.append(rpos + 1)
				lpos += 1
				rpos -= 1
			else:
				rpos -= 1
		else:
			lpos += 1
	if ans:
		print(1)
		print(len(ans))
		print(*sorted(ans))
	else:
		print(0)

def In():
	return map(int, input().split())

def complibook():
	(n, q) = In()
	nums = list(In())
	for _ in range(q):
		(l, r, x) = In()
		num = nums[x - 1]
		les = 0
		for i in range(l - 1, r):
			if nums[i] < num:
				les += 1
		print(['No', 'Yes'][les + l - 1 == x - 1])

def bstr():
	for _ in range(int(input())):
		(n, k) = In()
		now = 1
		times = 2
		while k > now:
			k -= now
			now += 1
			times += 1
		fir = n - times
		sec = n - k
		for i in range(n):
			if i == fir or i == sec:
				print('b', end='')
			else:
				print('a', end='')
		print()

def avgsuper():
	(n, k, oper) = In()
	l = sorted(In(), reverse=True)
	nowavg = sum(l) / n
	(addpos, addnum) = (0, 0)
	for i in range(oper):
		if n == 1 and addpos != 0:
			break
		new = (nowavg * n - l[n - 1]) / max(n - 1, 1)
		if 1 / n > new - nowavg and addpos < n:
			addnum += 1
			if addnum >= k:
				addpos += 1
				addnum = 0
			nowavg += 1 / n
		else:
			nowavg = new
			n -= 1
	print(nowavg)

def avgsuper2():
	(n, k, oper) = In()
	l = sorted(In(), reverse=True)
	prefix = [0] * (n + 1)
	for i in range(1, n + 1):
		prefix[i] = l[i - 1] + prefix[i - 1]
	prefix.pop(0)
	ans = 0
	for i in range(n - 1, max(-1, n - oper - 2), -1):
		ans = max(ans, (prefix[i] + min(k * (i + 1), oper - (n - i - 1))) / (i + 1))
	return ans

def tanna():
	(n, k, A, B) = (int(input()), int(input()), int(input()), int(input()))
	if k == 1:
		return (n - 1) * A
	x = n
	ans = 0
	while x != 1:
		if x < k:
			return ans + A * (x - 1)
		if not x % k:
			nexts = x // k
			ans += min(B, A * (x - nexts))
			x = nexts
		else:
			new = x % k
			ans += new * A
			x = x - new
	return ans

def segsqu():
	square = 1
	num = int(input())
	while num > square * square:
		square += 1
	cols = square
	rows = math.ceil(num / cols)
	print(cols + rows)

def ParallelUniverses():
	(n, k, m, t) = In()
	for _ in range(t):
		(sta, pos) = In()
		if sta:
			n += 1
			if pos - 1 < k:
				k += 1
		elif pos < k:
			k -= pos
			n -= pos
		else:
			n = pos
		print(n, k)

def treasure():
	num = int(input())
	choose = max((list(In()) for _ in range(num)))
	ch2 = min((list(In()) for _ in range(num)))
	print(choose[0] + ch2[0], choose[1] + ch2[1])

def tradingbus():
	(plan, m, cap) = In()
	l = []
	for _ in range(plan):
		name = input()
		l.append([list(In()) for _ in range(m)])
	ans = 0
	for i in range(plan):
		fix = l[i]
		for i1 in range(i + 1, plan):
			fix1 = l[i1]
			sellnew = []
			buynew = []
			for x in range(m):
				fnow = fix[x]
				f1now = fix1[x]
				sellnew.append([max(f1now[1] - fnow[0], 0), fnow[2]])
				buynew.append([max(fnow[1] - f1now[0], 0), f1now[2]])
			sellnew.sort(reverse=True)
			buynew.sort(reverse=True)
			sellc = cap
			buyc = cap
			sa = 0
			ba = 0
			for x in range(m):
				left = sellnew[x][1]
				if left > sellc:
					sa += sellnew[x][0] * sellc
					break
				else:
					sa += sellnew[x][0] * left
					sellc -= left
			for x in range(m):
				left = buynew[x][1]
				if left > buyc:
					ba += buynew[x][0] * buyc
					break
				else:
					ba += buynew[x][0] * left
					buyc -= left
			ans = max(ans, max(ba, sa))
	return ans

def catparty():
	n = int(input())
	colors = [0] * 10
	appeared = 0
	ans = 0
	pos = 1
	for i in In():
		if not colors[i - 1]:
			appeared += 1
		colors[i - 1] += 1
		for x in range(10):
			if colors[x]:
				l1 = colors[:]
				l1[x] -= 1
				l1 = set(l1)
				if 0 not in l1:
					if len(l1) == 1:
						ans = pos
						break
				elif len(l1) == 2 or len(l1) == 1:
					ans = pos
					break
		pos += 1
	return ans

def catpartyhard():
	maxn = int(100000.0 + 10)
	n = int(input())
	colors = [0] * maxn
	count = [0] * maxn
	pos = 1
	mx = 0
	ans = 0
	for i in input().split():
		i = int(i)
		ok = False
		count[colors[i]] -= 1
		colors[i] += 1
		count[colors[i]] += 1
		mx = max(colors[i], mx)
		if count[1] == pos:
			ok = 1
		elif count[pos] == 1:
			ok = 1
		elif count[mx] * mx == pos - 1 and count[1] == 1:
			ok = 1
		elif count[mx - 1] * (mx - 1) == pos - mx and count[mx] == 1:
			ok = 1
		if ok:
			ans = pos
		pos += 1
	return ans

def pergen():

	def decide():
		nonlocal pos
		next = posl[pos]
		for i in range(next, n):
			if l[i] >= pos + 1:
				if l[i] == pos + 1:
					pos += 1
				else:
					return 'NO'
			else:
				return
	for _ in range(int(input())):
		n = int(input())
		l = []
		pos = 0
		posl = [0] * n
		for i in input().split():
			i = int(i)
			l.append(i)
			posl[i - 1] = pos
			pos += 1
		pos = 0
		flag = 0
		while pos < n:
			ans = decide()
			if ans:
				print('NO')
				flag = 1
				break
		if not flag:
			print('YES')
pergen()


import sys
from collections import defaultdict
from copy import copy
R = lambda t=int: t(input())
RL = lambda t=int: [t(x) for x in input().split()]
RLL = lambda n, t=int: [RL(t) for _ in range(n)]

def solve():
	n = R()
	P = RL()
	m = l = P[0]
	for p in P[1:]:
		if l + 1 != p and p > m:
			print('No')
			return
		m = min(m, p)
		l = p
	print('Yes')
T = R()
for _ in range(T):
	solve()


from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect
import math

def test_case():
	n = int(input())
	a = list(map(int, input().split()))
	orig = [0 for i in range(n + 1)]
	rj = [i for i in range(n + 1)]
	count = defaultdict(lambda : set())
	count[1] = set([i + 1 for i in range(n)])
	curr = dict(zip([i + 1 for i in range(n)], [1 for i in range(n)]))
	maxval = 1
	for i in range(n):
		orig[a[i]] = i + 1
	for i in range(n):
		step = i + 1
		if orig[step] not in count[maxval]:
			return 'No'
		count[maxval].remove(orig[step])
		if orig[step] == n:
			rj[orig[step]] = -1
		else:
			rj[orig[step]] = rj[orig[step] + 1]
			if rj[orig[step]] != -1:
				old = curr[orig[step] + 1]
				if orig[step] + 1 in count[old]:
					count[old].remove(orig[step] + 1)
					count[old + 1].add(orig[step] + 1)
					curr[orig[step] + 1] = old + 1
					maxval = max(maxval, old + 1)
		while maxval > 0 and count[maxval] == set():
			maxval -= 1
	return 'Yes'
for _ in range(int(input())):
	ret = test_case()
	if ret:
		print(ret)


import sys
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, sys.stdin.readline().strip().split()))
	x = [0] * n
	for j in range(n):
		x[a[j] - 1] = j + 1
	f = 1
	nn = n
	start = x[0]
	for j in range(1, n):
		if nn - x[j - 1] > 0:
			if x[j] == x[j - 1] + 1:
				continue
			else:
				f = 0
			if j < n - 1 and x[j] == nn:
				nn == x[j + 1] - 1
		else:
			if j < n - 1:
				nn = x[j + 1] - 1
			continue
	if f:
		print('YES')
	else:
		print('NO')


def solve(arr, n):
	(i, ans) = (1, True)
	while ans and i < n:
		if arr[i] > arr[i - 1]:
			ans = ans & (arr[i] - 1 == arr[i - 1])
		i += 1
	return ans
t = int(input())
for _t in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if solve(a, n):
		print('Yes')
	else:
		print('No')


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	ans = False
	for i in range(n - 1):
		if a[i] == n:
			s.add(n)
		elif a[i] + 1 not in s and a[i + 1] != a[i] + 1:
			ans = True
			break
		else:
			s.add(a[i])
	if ans == True:
		print('No')
	else:
		print('Yes')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	poss = True
	for i in range(n - 1):
		if not (arr[i] > arr[i + 1] or arr[i] + 1 == arr[i + 1]):
			poss = False
			break
	print('YES' if poss else 'NO')


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	indexes = defaultdict()
	occupied = [0] * n
	for i in range(n):
		indexes[arr[i]] = i
	pref = -1
	flag = True
	for key in sorted(indexes):
		if pref == -1:
			occupied[indexes[key]] = 1
			if indexes[key] == n - 1:
				pref = -1
			else:
				pref = indexes[key] + 1
		elif occupied[pref] == 1:
			occupied[indexes[key]] = 1
			if indexes[key] == n - 1:
				pref = -1
			else:
				pref = indexes[key] + 1
		elif pref != indexes[key]:
			flag = False
			break
		else:
			occupied[indexes[key]] = 1
			if indexes[key] == n - 1:
				pref = -1
			else:
				pref = indexes[key] + 1
	if flag:
		print('Yes')
	else:
		print('No')


def check(sw, perm):
	mi = 0
	while True:
		ind = sw[mi]
		i = 1
		for i in range(1, n - ind - mi):
			if perm[ind + i] != mi + i + 1:
				return False
		mi = mi + i
		if mi >= n:
			return True
t = int(input())
for _ in range(t):
	n = int(input())
	perm = list(map(int, input().split()))
	sw = [0] * n
	for (i, p) in enumerate(perm):
		sw[p - 1] = i
	if check(sw, perm):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	kyu = True
	for i in range(1, n):
		if p[i] > p[i - 1] and p[i] - p[i - 1] != 1:
			kyu = False
	print('Yes' if kyu else 'No')


from sys import *
import collections
import math
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	p = list(map(int, stdin.readline().split(' ')))
	pos = [0] * (n + 1)
	for i in range(n):
		pos[p[i]] = i + 1
	l = n
	op = True
	com = 0
	res = True
	for i in range(1, n + 1, 1):
		if op:
			if pos[i] == l:
				l = l - 1
				continue
			till = l + 1
			l = pos[i] - 1
			op = False
			com = pos[i] + 1
			continue
		if pos[i] != com:
			res = False
			break
		com = com + 1
		if com == till:
			op = True
	if res:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	d = [0] * (n + 1)
	vis = [0] * (n + 1)
	ct = 1
	z = 1
	for i in range(n):
		d[ar[i]] = i
	while ct <= n:
		j = d[ct]
		while j < n and vis[j] != 1:
			vis[j] = 1
			if j < n - 1 and vis[j + 1] == 0 and (ar[j] + 1 != ar[j + 1]):
				z = 0
				print('No')
				break
			j += 1
		if z == 0:
			break
		ct += 1
	if z:
		print('Yes')


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	n = read_int()
	a = read_int_line()
	f = True
	ind = [-1] * n
	for i in range(n):
		ind[a[i] - 1] = i
	last = n
	nextele = 0
	last = n - 1
	while nextele < n:
		j = ind[nextele]
		cnt = nextele + 1
		while j < last:
			if a[j] + 1 != a[j + 1]:
				f = False
				break
			else:
				j += 1
				cnt += 1
		last = ind[nextele] - 1
		nextele = cnt
		if not f:
			break
	if f:
		print('Yes')
	else:
		print('No')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().split()]

def st():
	return input()

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li()
	ind = {}
	for i in range(n):
		ind[l[i]] = i + 1
	s = set([*range(1, n + 1)])
	takefromset = 1
	ans = 'Yes'
	currtochoose = 1
	while len(s):
		if takefromset:
			takefromset = 0
			if ind[currtochoose] in s:
				s.remove(ind[currtochoose])
			else:
				ans = 'No'
				break
			if ind[currtochoose] + 1 <= n and ind[currtochoose] + 1 in s:
				nex = ind[currtochoose] + 1
			else:
				takefromset = 1
		else:
			if nex == ind[currtochoose]:
				s.remove(nex)
			else:
				ans = 'No'
				break
			if nex + 1 <= n and ind[currtochoose] + 1 in s:
				nex += 1
			else:
				takefromset = 1
		currtochoose += 1
	print(ans)


t = int(input())
for _ in range(0, t):
	n = int(input())
	pp = [int(i) for i in input().split()]
	pos = [0] * (n + 1)
	for i in range(0, n):
		pos[pp[i]] = i + 1
	ans = 'Yes'
	for i in range(2, n + 1):
		if pos[i] > pos[i - 1] + 1:
			ans = 'No'
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(lambda x: int(x) - 1, input().split()))
	inv = [-1] * n
	for i in range(n):
		inv[arr[i]] = i
	ptr = 0
	vis = [False] * n + [True]
	flag = True
	while ptr != n:
		vis[inv[ptr]] = True
		if vis[inv[ptr] + 1] != True:
			if not vis[inv[ptr] + 1]:
				if arr[inv[ptr] + 1] != ptr + 1:
					flag = False
					break
		ptr += 1
	if flag:
		print('Yes')
	else:
		print('No')


for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1 and a == [1]:
		ans = 1
	else:
		ind = [-1] * (n + 1)
		ans = 1
		for i in range(n):
			ind[a[i]] = i
		filled = [-1] * (n + 1)
		filled[ind[1]] = 1
		for i in range(1, n - 1):
			if filled[ind[i] + 1] == 1 or ind[i] + 1 >= n:
				if ind[i + 1] > ind[i]:
					ans = 0
					break
			elif ind[i + 1] != ind[i] + 1:
				ans = 0
				break
			filled[ind[i + 1]] = 1
	if ans == 0:
		print('NO')
	else:
		print('YES')


import sys
from collections import *
from bisect import *
from math import *
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	co = [1 for i in range(n)]
	ind = []
	for i in range(n):
		ind.append([a[i], i])
	ind.sort()
	curmax = 1
	pos = ind[0][1]
	flag = 0
	for i in range(n):
		curind = ind[i][1]
		if curind != pos:
			flag = 1
			break
		if curind != n - 1:
			if co[curind + 1] != 0:
				co[curind + 1] += co[curind]
				if i != n - 1:
					pos = ind[i + 1][1]
			if co[curind + 1] > curmax:
				curmax = co[curind + 1]
				pos = curind + 1
			elif i != n - 1:
				pos = ind[i + 1][1]
		elif i != n - 1:
			pos = ind[i + 1][1]
		co[curind] = 0
	if flag == 1:
		print('No')
	else:
		print('Yes')


T = int(input())

def test(l):
	bord = len(l)
	v = 1
	for z in range(len(l) - 1, -1, -1):
		if l[z] == v:
			v += 1
			for j in range(z + 1, bord):
				v += 1
				if l[j] != l[j - 1] + 1:
					return False
			bord = z
	return True
for t in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	print('Yes' if test(l) else 'No')


from collections import defaultdict as dd

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	P = rl()
	for i in range(n - 1):
		if P[i + 1] > P[i] + 1:
			return 'No'
	return 'Yes'
t = ri()
for i in range(t):
	print(solve())


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	d = dd(int)
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		d[l[i]] = i
	i = 1
	lol = 0
	vis = [0] * n
	while i <= n:
		p = d[i]
		while vis[p] == 0 and p < n:
			vis[p] = 1
			if p + 1 == n:
				break
			if i + 1 == n + 1:
				break
			if vis[p + 1]:
				break
			if p + 1 != d[i + 1]:
				lol = 1
				break
			i += 1
			p += 1
		i += 1
	if lol:
		print('No')
	else:
		print('Yes')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	p = [*map(int, input().split())]
	ok = 'YES'
	for i in range(0, n - 1):
		if p[i + 1] - p[i] > 1:
			ok = 'NO'
			break
	print(ok)


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	small_idx = [0]
	for i in range(n - 1):
		if a[i + 1] < a[i]:
			small_idx.append(i + 1)
	end = n
	small_idx = small_idx[::-1]
	now = []
	for idx in small_idx:
		now.extend(a[idx:end])
		end = idx
	if now == list(range(1, n + 1)):
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	index = [0] * n
	for i in range(len(a)):
		index[a[i] - 1] = i
	ok = True
	for i in range(n - 1):
		if index[i + 1] > index[i] + 1:
			ok = False
			break
	if ok == False:
		print('No')
	else:
		print('Yes')


for t in range(int(input())):
	n = int(input())
	p = [int(i) for i in input().split()]
	valid = True
	for i in range(1, n):
		if p[i - 1] + 1 < p[i]:
			valid = False
			break
	if valid:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	if len(a) != len(s):
		print('No')
	else:
		f = 0
		for i in range(1, n):
			if a[i] > a[i - 1] and a[i] - a[i - 1] > 1:
				print('No')
				f = 1
				break
		if f == 0:
			print('Yes')


import sys
input = sys.stdin.readline
t = int(input())
for i1 in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	d = {}
	flag = True
	for i in range(n):
		d[l[i] - 1] = i
	v = [0] * n
	for i in range(n - 1):
		v[d[i]] = 1
		if d[i] != n - 1:
			if d[i] + 1 != d[i + 1] and v[d[i] + 1] == 0:
				flag = False
				break
	if flag == True:
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	f = 1
	prev = None
	for i in a:
		if prev == None:
			prev = i
		if i == prev + 1:
			prev = i
		elif i > prev + 1:
			f = 0
			break
		else:
			prev = i
	if f:
		print('Yes')
	else:
		print('No')


import sys
import bisect
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	p.insert(0, 0)
	index = {}
	for i in range(1, n + 1):
		index[p[i]] = i
	l = [0] * (n + 1)
	index1 = {}
	ch = 0
	i = 1
	j = n
	ch = 0
	while i <= n:
		if index[i] <= j:
			j = index[i] - 1
			index1[index[i]] = 1
			l[index[i]] = i
			i += 1
		else:
			ch = 1
			break
		k = j + 2
		while k <= n:
			if index1.get(k, -1) != -1:
				break
			elif i <= n:
				l[k] = i
				index1[k] = 1
				i += 1
			else:
				break
			k += 1
	if l == p:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ind = arr.index(1)
	flag = 1
	for i in range(ind + 1, n):
		if arr[i] == arr[i - 1] + 1:
			continue
		else:
			flag = 0
			break
	if flag == 0:
		print('No')
		continue
	num = arr[n - 1] + 1
	if num == n:
		print('Yes')
		continue
	start = ind - 1
	while start > 0:
		start = ind - 1
		while arr[start] != num:
			start -= 1
			if arr[start] + 1 != arr[start + 1]:
				flag = 0
				break
		if flag == 0:
			print('No')
			break
		num = arr[ind - 1] + 1
		ind = start
	if flag == 0:
		continue
	print('Yes')


def is_poss(n, p):
	d = {}
	stop = n
	focus = 1
	for (c, el) in enumerate(p):
		d[el] = c
	while True:
		focus_idx = d[focus]
		end = stop - focus_idx
		for i in range(1, end):
			if p[focus_idx + i] != focus + i:
				return False
		if focus_idx == 0:
			return True
		focus = p[stop - 1] + 1
		stop = focus_idx

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		p = list(map(int, input().split()))
		if is_poss(n, p):
			print('Yes')
		else:
			print('No')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = True
	for i in range(1, len(arr)):
		if arr[i] > arr[i - 1]:
			if arr[i] - 1 != arr[i - 1]:
				ans = False
	if ans:
		print('Yes')
	else:
		print('No')


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
t = inn()
for tt in range(t):
	n = inn()
	p = inl()
	ok = True
	tgt = 1
	nxt = p[n - 1]
	nxttgt = nxt + 1
	for i in range(n - 1, -1, -1):
		if p[i] != nxt:
			ok = False
			break
		if p[i] == tgt and i > 0:
			tgt = nxttgt
			nxt = p[i - 1]
			nxttgt = nxt + 1
		else:
			nxt -= 1
	print('Yes' if ok else 'No')


T = int(input())
for _ in range(T):
	n = int(input())
	nums = list(map(int, input().split()))
	nnums = list(enumerate(nums, 1))
	nnums.sort(key=lambda x: x[1])
	vis = [False] * 1000002
	pre = -1
	vis[n + 1] = True
	gg = False
	for (idx, num) in nnums:
		if pre == -1:
			vis[idx] = True
		elif idx != pre + 1:
			gg = True
			break
		else:
			vis[idx] = True
		pre = -1 if vis[idx + 1] else idx
	if gg:
		print('No')
	else:
		print('Yes')


def main_function():
	from sys import stdin
	from sys import stdout
	input = stdin.readline
	print = stdout.write
	t = int(input())
	for _ in range(t):
		n = int(input())
		considered_permutation = list(map(int, input().split()))
		if n <= 2:
			print('Yes\n')
			continue
		ix_in_permutation = [0] * n
		for i in range(n):
			ix_in_permutation[considered_permutation[i] - 1] = i
		count = [1] * n + [0]
		max_count = 1
		for i in range(n - 1):
			if count[ix_in_permutation[i]] != max_count:
				print('No\n')
				break
			if count[ix_in_permutation[i] + 1] == 0:
				max_count = 1
			else:
				max_count += 1
				count[ix_in_permutation[i] + 1] += count[ix_in_permutation[i]]
			count[ix_in_permutation[i]] = 0
		else:
			print('Yes\n')
main_function()


t = int(input())
for i in range(t):
	n = int(input())
	per = [int(k) for k in input().split()]
	i = n - 1
	tmp = n
	j = 1
	flag = 1
	while i >= 0:
		if flag == 0:
			break
		if per[i] != j:
			i -= 1
		else:
			for k in range(i, tmp):
				if per[k] != j:
					flag = 0
					break
				else:
					j += 1
			tmp = i
			i -= 1
	if flag == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	b = [0] * (n + 1)
	for i in range(n):
		b[p[i]] = i + 1
	e = 0
	for i in range(1, n):
		if b[i] > b[i + 1] or b[i + 1] - b[i] == 1:
			e = 0
		else:
			e = 1
			break
	if e == 0:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	t = [a[0]]
	for (u, v) in zip(a, a[1:]):
		if u + 1 != v:
			t.append(v)
	print('Yes' if all((u > v for (u, v) in zip(t, t[1:]))) else 'No')


import math
import collections
import sys
input = sys.stdin.readline

def check(a, start):
	count = 0
	for i in a[::-1]:
		if i == start + count:
			count += 1
		else:
			return False
	return True

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	z = []
	find = 1
	while a:
		z.append(a[-1])
		if find == a[-1]:
			if check(z, find):
				find = max(z) + 1
				z = []
			else:
				print('No')
				return
		a.pop()
	if not z:
		print('Yes')
	else:
		print('No')
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.buffer.readline

def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	n = int(input())
	p = I()
	arr = [0] * (n + 1)
	for i in range(n):
		arr[p[i]] = i
	last = n - 1
	f1 = 0
	f = 0
	last = n - 1
	f = 0
	f = 0
	last = n - 1
	i = 1
	while i < n + 1:
		if arr[i] == last:
			last -= 1
			i += 1
		else:
			prev = arr[i]
			c = last - arr[i]
			i += 1
			if i > n:
				break
			while i < n + 1 and c > 0:
				if arr[i] - 1 != arr[i - 1]:
					f = 1
					break
				i += 1
				c -= 1
			last = prev - 1
	if not f:
		print('Yes')
	else:
		print('No')


import sys
import heapq
input = sys.stdin.readline

def good(pos, n):
	heapmx = [(-1, i) for i in range(n)]
	heapq.heapify(heapmx)
	cnt = [1] * n
	prev_free = [i - 1 if i > 0 else None for i in range(n)]
	next_free = [i + 1 if i < n - 1 else None for i in range(n)]
	for x in range(n):
		while cnt[heapmx[0][1]] == 0:
			heapq.heappop(heapmx)
		i = pos[x]
		if cnt[i] != -heapmx[0][0]:
			return False
		cnt[i] = 0
		if next_free[i]:
			prev_free[next_free[i]] = prev_free[i]
			cnt[next_free[i]] = next_free[i] - (prev_free[i] or 0) + 1
			heapq.heappush(heapmx, (-cnt[next_free[i]], next_free[i]))
		if prev_free[i]:
			next_free[prev_free[i]] = next_free[i]
	return True
for _ in range(int(input())):
	n = int(input())
	pos = {x - 1: i for (i, x) in enumerate(list(map(int, input().split())))}
	print('Yes' if good(pos, n) else 'No')


t = int(input())
for pp in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.append(-1)
	pt1 = 0
	pt2 = 0
	while pt1 != n:
		ele = arr[pt1]
		if ele == -1:
			break
		for i in range(pt1 + 1, n + 1):
			if arr[i] - ele == 1:
				pt2 = i
				ele = arr[i]
			else:
				for j in range(pt1, pt2 + 1):
					arr[j] = ele
				break
		pt1 = pt2 + 1
		pt2 = pt1
	ip = []
	dct = {}
	for i in arr:
		if i != -1:
			if i not in dct:
				ip.append(i)
				dct[i] = 1
	pi = []
	for i in ip:
		pi.append(i)
	pi.sort(reverse=True)
	if pi == ip:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	check = 0
	for i in range(0, n - 1):
		if l[i] < l[i + 1]:
			if l[i + 1] != l[i] + 1:
				check = 1
				break
	if check == 0:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	flag = True
	high = n + 1
	for i in range(1, n):
		if a[i - 1] != a[i] - 1:
			high = a[i - 1]
		if a[i] >= high:
			flag = False
			break
	if flag:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	prev = p[0]
	lim = p[0]
	cflag = 0
	for i in range(1, n):
		if p[i] != p[i - 1] + 1:
			if p[i] < lim:
				lim = p[i]
			else:
				print('No')
				cflag = 1
				break
	if cflag == 0:
		print('Yes')


import sys
from math import ceil
from itertools import islice, cycle
from collections import Counter
stdin = sys.stdin
t = int(stdin.readline())
for line in stdin:
	if not line:
		break
	n = int(line.strip())
	table = stdin.readline().split()
	for (a, b) in zip(table, table[1:]):
		a = int(a)
		b = int(b)
		if b > a + 1:
			print('No')
			break
	else:
		print('Yes')


from sys import stdout, stdin
input = stdin.readline
print = stdout.write
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 'Yes\n'
	index = [0 for i in range(n)]
	for i in range(n):
		index[a[i] - 1] = i
	flag = 0
	for i in range(n - 1):
		if flag == 1:
			if index[i] != index[i - 1] + 1:
				ans = 'No\n'
				break
		if index[i] != n - 1:
			if a[index[i] + 1] > a[index[i]]:
				flag = 1
			else:
				flag = 0
		else:
			flag = 0
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if l == sorted(l) or l == sorted(l, reverse=True):
		print('Yes')
	else:
		d = {}
		for i in range(n):
			d[l[i]] = i
		s = set()
		f = True
		for i in range(1, n + 1):
			if i not in s:
				start = d[i]
				s.add(l[start])
				for j in range(start, n - 1):
					s.add(l[j])
					if l[j + 1] in s:
						break
					if l[j] + 1 != l[j + 1] and l[j + 1] not in s:
						f = False
						break
			if not f:
				break
		if f:
			print('Yes')
		else:
			print('No')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def solve(n, P):
	if n == 1:
		return 'YES'
	P.reverse()
	for i in range(n - 1):
		if P[i + 1] < P[i] and P[i] - P[i + 1] != 1:
			return 'NO'
	for i in range(1, n):
		if P[i] > P[i - 1]:
			if P[i - 1] != 1:
				return 'NO'
			break
	peak = P[0]
	next_idx = i
	for j in range(i + 1, n):
		if P[j] > P[j - 1]:
			if P[j - 1] != peak + 1:
				return 'NO'
			peak = P[next_idx]
			next_idx = j
	return 'YES'

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		P = list(map(int, input().split()))
		ans = solve(n, P)
		sys.stdout.write(str(ans) + '\n')
main()


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		dic[ar[i]] = i
	leftmost = n
	j = 1
	flag = True
	left = [dic[1]]
	right = n
	ini = dic[1]
	for i in range(1, n + 1):
		if left[-1] == right:
			right = ini
			ini = dic[i]
			left.append(ini)
		if dic[i] != left[-1]:
			flag = False
			break
		else:
			left.append(left[-1] + 1)
	if flag:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ch = 1
	i = 1
	while i <= n:
		j = len(a) - 1
		cn = 0
		while 1:
			if a[j] == i:
				cn += 1
				a.pop()
				break
			if a[j] - a[j - 1] == 1:
				a.pop()
				cn += 1
				j -= 1
			else:
				ch = 0
				break
		if ch == 0:
			break
		i += cn
	if ch == 1:
		stdout.write('Yes' + '\n')
	else:
		stdout.write('No\n')


for t in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	ans = 'Yes'
	for i in range(1, n):
		if p[i] - p[i - 1] > 1:
			ans = 'No'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if len(list(set(l))) < n:
		print('NO')
	else:
		f = 0
		for i in range(1, n):
			if l[i] > l[i - 1]:
				if l[i - 1] + 1 != l[i]:
					f = 1
					break
		if f == 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	answer = 'Yes'
	for i in range(len(arr) - 1):
		if arr[i + 1] > arr[i] + 1:
			answer = 'No'
			break
	print(answer)


def main():
	import sys
	input = sys.stdin.buffer.readline

	def GCD(x, y):
		while y:
			(x, y) = (y, x % y)
		return x

	def lcm(a, b):
		return a * b // GCD(a, b)

	def merge(a, start, mid, end, d):
		p = start
		q = mid + 1
		arr = [0] * (end - start + 1)
		k = 0
		coun = 0
		for i in range(start, end + 1):
			if p > mid:
				arr[k] = a[q]
				q += 1
				k += 1
			elif q > end:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			elif a[p] < a[q]:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			else:
				arr[k] = a[q]
				k += 1
				q += 1
				coun += 1
		for i in range(k):
			a[start] = arr[i]
			start += 1

	def mergesort(a, start, end, d):
		if start < end:
			mid = (start + end) // 2
			mergesort(a, start, mid, d)
			mergesort(a, mid + 1, end, d)
			merge(a, start, mid, end, d)

	def inversion(l):
		d = {}
		for i in l:
			d[i] = 0
		mergesort(l, 0, len(l) - 1, d)
		return d

	def binary_search_lower(A, low, high, k):
		if high - low != 1:
			mid = (low + high) // 2
			x = A[mid]
			if x >= k:
				return binary_search_lower(A, low, mid, k)
			else:
				return binary_search_lower(A, mid, high, k)
		if A[low] >= k:
			return low
		else:
			return high

	def binary_expo(x, n):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return binary_expo(x * x, n // 2)
		else:
			return x * binary_expo(x * x, (n - 1) // 2)

	def modu_expo(x, n, m):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return modu_expo(x * x % m, n // 2, m)
		else:
			return x * modu_expo(x * x % m, (n - 1) // 2, m) % m

	def eEuclid(c, m):
		if m == 0:
			global d
			global x
			global y
			d = c
			x = 1
			y = 0
		else:
			eEuclid(m, c % m)
			temp = x
			x = y
			y = temp - c // m * y

	def mod_Inv(c, m):
		eEuclid(c, m)
		return (x % m + m) % m

	def ncr(n, r, p):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % p
			den = den * (i + 1) % p
		return num * pow(den, p - 2, p) % p
	for _ in range(int(input())):
		n = int(input())
		l = [int(y) for y in input().split()]
		l.append('x')
		x = [0] * (n + 1)
		for i in range(n):
			x[l[i]] = i
		for i in range(1, n):
			if x[i + 1] - x[i] == 1:
				l[x[i]] = 'x'
			elif x[i + 1] - x[i] != 1 and 'x' == l[x[i] + 1]:
				l[x[i]] = 'x'
			else:
				print('NO')
				break
		else:
			print('YES')
main()


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	hash = defaultdict(int)
	for i in range(n):
		hash[l[i]] = i
	cur = 1
	seti = set()
	flag = 0
	while True:
		z = hash[cur]
		seti.add(z)
		while z < n - 1 and z + 1 not in seti:
			if l[z + 1] - l[z] == 1:
				cur = l[z + 1]
			else:
				flag = 1
				break
			z += 1
			if z + 1 in seti:
				break
		if flag:
			break
		cur += 1
		if cur == n + 1:
			break
	if not flag:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	for i in range(1, n):
		x = arr[i] - arr[i - 1]
		if x != 1 and x >= 0:
			break
	else:
		print('Yes')
		continue
	print('No')


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Query.append((N, A))

def check(N, A):
	for i in range(N - 1):
		(a, b) = (A[i], A[i + 1])
		if b != a + 1 and b > a:
			return False
	return True
for (N, A) in Query:
	print('Yes' if check(N, A) else 'No')


t = int(input())
for inp in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	index = [0 for i in range(n + 1)]
	for i in range(n):
		index[l[i]] = i + 1
	i = 1
	end = n
	flag = 0
	while i < n + 1 and flag == 0:
		j = index[i]
		count = 1
		while j < end:
			if i + count == l[j]:
				j += 1
				count += 1
			else:
				flag = 1
				break
		end = index[i] - 1
		i += count
	if flag == 1:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	free = True
	pos = [0] * n
	id = [0] * (n + 1)
	pos.append(1)
	c = 0
	res = True
	for i in range(n):
		id[p[i]] = i
	for i in range(1, n + 1):
		if free:
			c = id[i] + 1
			pos[c - 1] = 1
			if pos[c]:
				c = 0
				free = True
			else:
				free = False
		elif id[i] != c:
			res = False
			break
		else:
			c += 1
			pos[c - 1] = 1
			if pos[c]:
				c = 0
				free = True
			else:
				free = False
	print('YNeos'[not res::2])


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	D = {i: 0 for i in range(n)}
	for i in range(n):
		D[A[i] - 1] = i
	X = [i for i in range(n)]
	count = [1 for _ in range(n)]
	p = 'Yes'
	peak = n - 1
	st = 0
	for i in range(n):
		if D[i] != peak:
			if i != n - 1:
				if D[i + 1] != D[i] + 1:
					p = 'No'
		else:
			peak = D[st] - 1
			st = i + 1
	print(p)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	pos = [0] * n
	visited = [0] * n
	for i in range(n):
		pos[l[i] - 1] = i
	visited[pos[0]] = 1
	temp = 1
	flag = 0
	while temp < n:
		if pos[temp - 1] == n - 1 or visited[pos[temp - 1] + 1] == 1:
			visited[pos[temp]] = 1
			temp += 1
			continue
		elif pos[temp - 1] + 1 != pos[temp]:
			print('No')
			flag = 1
			break
		else:
			visited[pos[temp]] = 1
		temp += 1
	if flag == 0:
		print('Yes')
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	values = list(map(int, input().split()))
	check = True
	indices = [0] * (n + 1)
	for i in range(n):
		indices[values[i]] = i + 1
	for i in range(2, n + 1):
		if i == 2:
			if indices[i] == indices[i - 1] + 1 or indices[i - 1] == n:
				continue
			else:
				check = False
				break
		elif indices[i] == indices[i - 1] + 1 or indices[i] < indices[i - 1]:
			continue
		else:
			check = False
			break
	if check:
		print('Yes')
	else:
		print('No')


def rn():
	a = int(input())
	return a

def rl():
	a = list(map(int, input().split()))
	return a
for _ in range(int(input())):
	n = rn()
	p = rl()
	last = [i for i in range(n, 0, -1)]
	ans = []
	i = 0
	j = 1
	while j < n:
		if p[j - 1] > p[j]:
			for k in range(j - 1, i - 1, -1):
				ans.append(p[k])
			i = j
			j += 1
		else:
			j += 1
	for k in range(j - 1, i - 1, -1):
		ans.append(p[k])
	if ans == last:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	poss = {}
	for i in range(n):
		poss[arr[i]] = i
	poss[n + 1] = 0
	right = n
	start = poss[1]
	pos = poss[1]
	next = 1
	while 1:
		if arr[pos] == next:
			pos += 1
			next += 1
		else:
			print('No')
			break
		if pos == right:
			right = start
			start = poss[next]
			pos = poss[next]
		if next == n + 1:
			print('Yes')
			break


r = input
for _ in range(int(r())):
	a = n = int(r())
	s = 'Yes'
	for q in r().split():
		b = int(q)
		if b > a:
			s = 'No'
		a = b + 1
	print(s)


import math
import random

def task_1343_c():
	b = int(input())
	array = [int(num) for num in input().split()]
	maxPositive = 0
	minNegative = -10000000000
	res = 0
	for i in range(b):
		if array[i] < 0:
			if i != 0 and array[i - 1] >= 0:
				res += maxPositive
				maxPositive = 0
			minNegative = max(minNegative, array[i])
		elif i != 0 and array[i - 1] < 0:
			res += minNegative
			minNegative = -10000000000
		maxPositive = max(maxPositive, array[i])
	if minNegative == -10000000000:
		res += maxPositive
	else:
		res += maxPositive + minNegative
	print(res)

def task_1341_b():
	(heightLen, doorSize) = map(int, input().split())
	heights = [int(num) for num in input().split()]
	perf = [0 for i in range(heightLen)]
	a = 0
	for i in range(heightLen - 1):
		if i == 0:
			perf[i] = 0
		else:
			if heights[i - 1] < heights[i] and heights[i] > heights[i + 1]:
				a += 1
			perf[i] = a
	perf[heightLen - 1] = a
	max_global = 0
	left_global = 0
	for i in range(heightLen - doorSize):
		max_local = perf[i + doorSize - 1] - perf[i]
		if max_local > max_global:
			max_global = max_local
			left_global = i
	print(max_global + 1, left_global + 1)

def task_1340_a():
	n = int(input())
	if n == 1:
		a = int(input())
		if a != 1:
			print('No')
			return
	else:
		array = [int(i) for i in input().split()]
		for i in range(n - 1):
			if array[i] < array[i + 1]:
				if array[i] + 1 != array[i + 1]:
					print('No')
					return
	print('Yes')

def task_1339_b():
	n = int(input())
	array = [int(num) for num in input().split()]
	array.sort()
	output = [0 for i in range(0, n)]
	i = 0
	h = 0
	j = n - 1
	while i <= j:
		output[h] = array[i]
		h += 1
		i += 1
		if h < n:
			output[h] = array[j]
			h += 1
			j -= 1
	for val in reversed(output):
		print(val, end=' ')

def task_1338_a():
	n = int(input())
	inputArr = [int(num) for num in input().split()]
	max_sec = 0
	for i in range(1, n):
		local_sec = 0
		a = inputArr[i - 1] - inputArr[i]
		if a <= 0:
			continue
		else:
			b = math.floor(math.log2(a))
			local_sec = b + 1
			for j in range(b, -1, -1):
				if a < pow(2, j):
					continue
				inputArr[i] += pow(2, j)
				a -= pow(2, j)
			if local_sec > max_sec:
				max_sec = local_sec
	print(max_sec)
a = int(input())
for i in range(a):
	task_1340_a()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	i = 1
	s = 0
	while i <= n:
		idx = p.index(i)
		if p[idx:] != list(range(i, i + len(p) - idx)):
			print('No')
			s = 1
			break
		i += len(p) - idx
		p = p[:idx]
	if s == 1:
		continue
	print('Yes')


def task(n, p):
	start = -1
	prev = -1
	for i in range(0, len(p)):
		if start == -1:
			start = p[i]
		elif prev > p[i]:
			start = p[i]
		elif prev + 1 < p[i]:
			print('No')
			return
		prev = p[i]
	print('Yes')
t = int(input())
for i in range(0, t):
	n = int(input())
	p = list(map(int, input().split()))
	task(n, p)


import sys
import math

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def bfs(graph, start_ver):
	visited = set()
	queue = [[start_ver, 0]]
	visited.add(start_ver)
	(ans_way_length, ans_ver) = (0, 1)
	while queue:
		ver = queue[0]
		queue = queue[1:]
		for new_ver in graph[ver[0]]:
			if new_ver not in visited:
				visited.add(new_ver)
				queue += [[new_ver, ver[1] + 1]]
				if ans_way_length < ver[1] + 1:
					(ans_ver, ans_way_length) = (new_ver, ver[1] + 1)
	return (ans_ver, ans_way_length)

def dfs(graph, ver):
	used_v = set()
	depth = [0] * (len(graph) + 1)
	level = [ver]
	num_of_level = 0
	while level:
		new_level = []
		for v in level:
			depth[v] = num_of_level
			used_v.add(v)
			for v1 in graph[v]:
				if v1 not in used_v:
					new_level += [v1]
		level = new_level
		num_of_level += 1
	return depth

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def c_mod(n1, k1, mod1):
	num = den = 1
	for i in range(n1 - k1):
		num = num * (n1 - i) % mod1
		den = den * (i + 1) % mod1
	return num * pow(den, mod1 - 2, mod1) % mod1

def c(n1, k1):
	num = den = 1
	for i in range(n1 - k1):
		num = num * (n1 - i)
		den = den * (i + 1)
	return num // den

def v_sistemu(x, k):
	x = int(x)
	z = ''
	while x:
		z += str(x % k)
		x //= k
	return z[::-1]

def iz_sistemi(x, k):
	x = str(x)[::-1]
	ans = 0
	for i in range(len(x)):
		ans += int(x[i]) * pow(k, i)
	return ans

def solve_of_problem():
	n = int(ii())
	data = idata()
	maxx = 1
	flag = True
	maxxx = data[-1]
	for i in range(n - 1, 0, -1):
		if data[i] == data[i - 1] + 1:
			pass
		elif data[i] > data[i - 1] + 1:
			print('NO')
			flag = False
			break
		else:
			if maxx != data[i]:
				print('NO')
				flag = False
				break
			maxx = maxxx + 1
			maxxx = data[i - 1]
	if flag:
		print('YES')
	return
for ______ in range(int(ii())):
	solve_of_problem()


for j in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	t = True
	for i in range(n - 1):
		if not (A[i + 1] == A[i] + 1 or A[i + 1] < A[i]):
			t = False
	if t:
		print('Yes')
	else:
		print('No')


import sys
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(stdin.readline().rstrip())
nm = lambda : map(int, stdin.readline().split())
nl = lambda : list(map(int, stdin.readline().split()))

def solve():
	n = ni()
	a = nl()
	c = 0
	while a:
		y = t = a[-1]
		while t > c:
			if a[-1] != t:
				return False
			a.pop()
			t -= 1
		c = y
	return True
t = ni()
for _ in range(t):
	print('Yes' if solve() else 'No')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if a[i] > a[i + 1] or a[i] - a[i + 1] == -1:
			pass
		else:
			print('No')
			break
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = [0]
	for i in range(n - 1):
		if a[i + 1] < a[i]:
			l.append(i + 1)
	l.append(n)
	for i in range(len(l) - 1):
		p = l[i]
		q = l[i + 1]
		ar = a[p:q]
		if max(ar) - min(ar) + 1 != q - p:
			print('No')
			break
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	f = True
	for i in range(1, n):
		if p[i] > p[i - 1]:
			if p[i] - p[i - 1] != 1:
				print('No')
				f = False
				break
	if f:
		print('Yes')


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(len(l)):
		d[l[i]] = i + 1
	high = n
	i = 1
	flag = 0
	while i <= n:
		low = d[i]
		for j in range(low, high + 1):
			if i <= n:
				if d[i] != j:
					flag = 1
					break
			else:
				flag = 1
				break
			i += 1
		if flag == 1:
			break
		high = low - 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	x = [int(w) for w in input().split()]
	i = 1
	last = n
	flag = 0
	while i < n:
		ind = x.index(i)
		if ind == last - 1:
			last = ind
			i += 1
			continue
		j = ind + 1
		flag = 0
		while j < last:
			i += 1
			if x[j] != i:
				flag = 1
				break
			j += 1
		last = ind
		if flag:
			print('NO')
			break
		i += 1
	if not flag:
		print('YES')


from sys import stdin

def solve(n, p):
	h = [1 for i in range(n + 1)]
	m = 1
	k = {}
	ans = 'Yes'
	for i in range(n):
		k[p[i]] = i + 1
	for i in range(1, n + 1):
		y = k[i]
		if h[y] != m:
			ans = 'No'
			break
		if y != n and h[y + 1] != 0:
			h[y + 1] += 1
			m = h[y + 1]
		else:
			m = 1
		h[y] = 0
	print(ans)

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		n = int(inp())
		p = list(map(int, inp().split()))
		solve(n, p)
main()


import sys
lines = sys.stdin.readlines()
T = int(lines[0].strip())
for t in range(T):
	n = int(lines[2 * t + 1].strip())
	nums = list(map(int, lines[2 * t + 2].strip().split(' ')))

	def check(n, nums):
		pt = n - 1
		cache = [0]
		for i in range(1, n):
			if nums[i] != nums[i - 1] + 1:
				cache.append(i)
		curr = 1
		prev = n
		for i in cache[::-1]:
			for j in range(i, prev):
				if curr != nums[j]:
					return False
				curr += 1
			prev = i
		return True
	if check(n, nums):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	flg = 0
	for j in range(n - 1):
		if p[j] - p[j + 1] <= -2:
			flg = 1
			break
	if flg:
		print('No')
	else:
		print('Yes')


for t in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	i = 0
	while i < n - 1:
		if list1[i + 1] < list1[i]:
			i += 1
		elif list1[i + 1] == list1[i] + 1:
			i += 1
		else:
			break
	if i == n - 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	t = n
	j = 1
	rt = 0
	indw = dict()
	for j in range(n):
		indw.update({l[j]: j})
	j = 1
	while j <= n:
		ind = indw[j]
		for k in range(ind, t):
			if l[k] == j:
				j += 1
				continue
			else:
				rt = 1
				break
		if rt == 0:
			t = ind
	if rt == 0:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	r = {}
	for i in range(n):
		r[p[i]] = i
	pos = r[1]
	st = pos
	lim = n - 1
	flag = 1
	for i in range(2, n + 1):
		if pos == lim:
			pos = r[i]
			lim = st - 1
			st = r[i]
		else:
			if r[i] != pos + 1:
				flag = 0
				break
			pos = r[i]
	if flag == 0:
		print('No')
	else:
		print('Yes')


def main():
	T = int(input())
	results = []
	for i in range(T):
		n = int(input())
		p = [int(i) for i in input().split()]
		result = 'Yes'
		for i in range(n - 1):
			if p[i + 1] - p[i] > 1:
				result = 'No'
				break
		results.append(result)
	for result in results:
		print(result)
main()


from sys import stdin, stdout
from math import *
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[ar[i]] = i
	p = [0] * (n + 1)
	ans = 'Yes'
	for i in range(1, n + 1):
		if i == 1:
			r = d[i] + 1
			p[d[i]] = 1
			if r >= n:
				r = -1
		elif r == -1:
			k = d[i]
			p[k] = 1
			if k < n - 1 and p[k + 1] == 0:
				r = k + 1
		else:
			k = d[i]
			if r != k:
				ans = 'No'
				break
			else:
				p[k] = 1
				if k < n - 1 and p[k + 1] == 0:
					r = k + 1
				else:
					r = -1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = 0
	i = 0
	u = 0
	while i < n:
		if a[i] < n - i:
			k = n - a[i] - i
			for j in range(0, k):
				if a[j + i + 1] - a[j + i] == 1:
					continue
				else:
					u = 1
					break
			if u != 1:
				i = i + k + 1
			else:
				break
		else:
			i += 1
	if u == 1:
		print('No')
	else:
		print('Yes')


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	maax = p[-1]
	start = p[-1]
	miin = 1
	current = p[-1]
	i = n - 2
	flag = 0
	while i >= 0:
		if maax > p[i] >= miin:
			if p[i] == current - 1:
				current = p[i]
			else:
				flag = 1
				break
		elif p[i] > maax:
			if current == miin:
				miin = maax + 1
				current = p[i]
				maax = p[i]
			else:
				flag = 1
				break
		i -= 1
	if flag == 1:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = a[::-1]
	end_point = 1
	start_point = a[0]
	flag = 1
	i = 0
	while i < n - 1 and end_point <= n:
		if a[i] == end_point:
			i += 1
			end_point = start_point + 1
			if i < n:
				start_point = a[i]
			else:
				break
		elif a[i] - a[i + 1] == 1:
			i += 1
		else:
			flag = 0
			break
	if flag == 0:
		print('No')
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	z = 0
	i = 1
	while i < n + 1:
		if a[n - i] == i:
			i += 1
			continue
		else:
			j = a.index(i)
			l = n - i - j
			zz = i
			for x in range(l):
				if a[j + 1] == zz + 1:
					j += 1
					zz += 1
				else:
					z += 1
					break
			i = zz + 1
		if i == n or z > 0:
			break
	if z == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for loop in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	nf = float('inf')
	now = float('inf')
	ans = 'Yes'
	for i in p:
		if i == now + 1:
			now += 1
		elif i > nf:
			ans = 'No'
			break
		else:
			nf = i
			now = i
	print(ans)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = [''] * t
	for ti in range(t):
		n = int(input())
		p = list(map(int, input().split()))
		ans_a[ti] = 'Yes' if all((p[i] + 1 == p[i + 1] or p[i] > p[i + 1] for i in range(n - 1))) else 'No'
	output(*ans_a)
main()


def solve(p):
	if len(p) <= 2:
		return True
	looking_for = 1
	max_filled = len(p)
	while looking_for <= len(p):
		index = p.index(looking_for)
		looking_for += 1
		for i in range(index + 1, max_filled):
			if p[i] != looking_for:
				return False
			looking_for += 1
		max_filled = index
	return True
for i in range(int(input())):
	n = int(input())
	p = [int(x) for x in input().split()]
	print('Yes' if solve(p) else 'No')


for _ in range(int(input())):
	n = int(input())
	arr = tuple(map(int, input().split()))
	indexes = {}
	for (index, i) in enumerate(arr):
		indexes[i] = index
	err = False
	max_index = n - 1
	pot_max_index = -1
	last_index = n - 1
	for i in range(1, n + 1):
		if pot_max_index == -1:
			pot_max_index = indexes[i] - 1
		if last_index < max_index and indexes[i] != last_index + 1:
			err = True
			break
		if indexes[i] == max_index:
			max_index = pot_max_index
			pot_max_index = -1
		last_index = indexes[i]
	if err:
		print('No')
	else:
		print('Yes')


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = L()
	ans = 'Yes'
	for i in range(n - 1):
		if a[i + 1] > a[i] + 1:
			ans = 'No'
			break
	print(ans)


import bisect

def solve():
	n = int(input())
	lis = list(map(int, input().split()))
	cond = True
	if len(lis) > 2:
		for (i, v) in enumerate(lis[1:], 1):
			if lis[i - 1] + 1 < lis[i]:
				cond = False
	if cond:
		print('Yes')
	else:
		print('No')
t = int(input())
for i in range(t):
	solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	for i in range(1, n):
		if a[i] > a[i - 1] and a[i] - a[i - 1] != 1:
			f = 1
			break
	if f:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	permutationlist = list(map(int, input().split()))
	indexstored = {}
	for i in range(n):
		indexstored[permutationlist[i]] = i + 1
	curr_last = n
	flag = True
	j = 1
	while j <= n:
		my_index = indexstored[j]
		k = my_index
		while k <= curr_last - 1:
			if permutationlist[k] == permutationlist[k - 1] + 1:
				k += 1
				j += 1
			else:
				flag = False
				break
				j = n
		if not flag:
			break
		curr_last = my_index - 1
		j += 1
	if flag:
		print('Yes')
	else:
		print('No')


from array import array
from math import log

def solve(data):
	if len(data) == 1:
		return 'Yes'
	sol = []
	s = 0
	last = data[0]
	for i in range(1, len(data)):
		if data[i] != last + 1:
			sol += [{'start': s, 'end': i - 1, 'from': data[s], 'to': data[i - 1]}]
			s = i
		last = data[i]
	if data[-1] != data[-2] + 1:
		sol += [{'start': s, 'end': i, 'from': data[s], 'to': data[i]}]
	for i in range(len(sol) - 1, 0, -1):
		if sol[i]['to'] != sol[i - 1]['from'] - 1:
			return 'No'
	return 'Yes'
test_cases = int(input())
for i in range(test_cases):
	input()
	data = [int(a) for a in input().split(' ')]
	print(solve(data))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	dic = {}
	for i in range(n):
		dic[a[i]] = i
	boo = True
	c = 0
	ans = True
	key = n - 1
	pos = {}
	cur = 0
	for i in range(n - 1):
		if dic[i + 1] == key and boo:
			key -= 1
			pos[key + 1] = 1
			continue
		elif boo:
			boo = False
			key = dic[i + 1] - 1
			pos[key + 1] = 1
			c = dic[i + 1] + 1
			continue
		if dic[i + 1] == c:
			c += 1
			pos[c] = 1
			if key + i + 2 == n:
				boo = True
		else:
			ans = False
			break
	ans1 = 'YES' if ans else 'NO'
	print(ans1)


import os
import unittest
import heapq

def task_a():
	t = int(input())
	for _ in range(t):
		(n, a, b, c, d) = map(int, input().split())
		it1 = ((a - b) * n, (a + b) * n)
		it2 = (c - d, c + d)
		if it1[0] <= it2[1] and it1[1] >= it2[0]:
			print('YES')
		else:
			print('NO')

def task_b():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		run_start = best_start = 0
		run_peaks = best_peaks = 0
		for i in range(n):
			if i > 1:
				if a[i - 2] < a[i - 1] > a[i]:
					run_peaks += 1
				if i > k - 1:
					if a[i - k] < a[i - k + 1] > a[i - k + 2]:
						run_peaks -= 1
				if run_peaks > best_peaks:
					best_peaks = run_peaks
					best_start = max(0, i - k + 1)
		print(best_peaks + 1, best_start + 1)

def task_c():

	def solve():
		n = int(input())
		a = list(map(int, input().split()))
		last = n + 1
		can_rand = True
		used = set()
		max_pq = [-x for x in reversed(range(1, n + 1))]
		heapq.heapify(max_pq)
		for i in range(n):
			if can_rand:
				if a[i] != last - 1:
					can_rand = False
			elif a[i] != last + 1:
				return 'No'
			last = a[i]
			used.add(a[i])
			if max_pq and a[i] == -max_pq[0]:
				while max_pq and -max_pq[0] in used:
					last = -heapq.heappop(max_pq)
				can_rand = True
		return 'Yes'
	t = int(input())
	for _ in range(t):
		print(solve())
task_c()


def yes():
	global p, n
	i = n + 1
	while i > 0:
		j = i - 1
		if j < 1:
			break
		while p[j - 1] + 1 == p[j]:
			j -= 1
		if p[i - 1] != n - j + 1:
			return False
		i = j
	return True
for i in range(int(input())):
	n = int(input())
	p = [n + 1] + list(map(int, input().split())) + [0]
	if yes():
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = 0
	for i in range(1, n):
		if arr[i] > arr[i - 1]:
			if arr[i] - arr[i - 1] != 1:
				flag = 1
				break
	if flag == 1:
		print('No')
	else:
		print('Yes')


t = int(input())
for case in range(t):
	n = int(input())
	numbers = [int(x) for x in input().split()]
	possible = True
	for i in range(n - 1):
		if numbers[i + 1] > numbers[i] + 1:
			possible = False
	if possible:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	s = set()
	flag = False
	while i < n:
		if a[i] == n:
			s.add(a[i])
			i += 1
			continue
		if a[i] in s:
			flag = True
			break
		else:
			s.add(a[i])
			temp = a[i]
			temp += 1
			j = i + 1
			while j < n:
				if a[j] == temp:
					j += 1
					temp += 1
				elif temp in s or temp > n:
					i = j
					break
				else:
					flag = True
					break
			if j == n:
				i = n
		if flag:
			break
	if flag:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7

def getlist():
	return list(map(int, input().split()))

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		P = getlist()
		judge = 'Yes'
		for i in range(N - 1):
			if P[i] + 1 == P[i + 1] or P[i] > P[i + 1]:
				pass
			else:
				judge = 'No'
				break
		print(judge)
main()


from collections import defaultdict as dc
from heapq import *
import math
import bisect
import sys
from collections import deque as dq
from heapq import heapify, heappush, heappop
mod = 10 ** 12

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def check(a):
	for i in range(1, len(a)):
		if a[i] != a[i - 1] + 1:
			return 0
	return 1

def solve(a):
	if len(a) <= 1:
		return 1
	if check(a):
		return 1
	if check(a[::-1]):
		return 1
	for i in range(len(a)):
		if a[i] == 1:
			z = i
			break
	l = len(a) - z
	for i in range(z):
		a[i] = a[i] - l
		if a[i] <= 0:
			return 0
	if solve(a[:z]) and check(a[z:]):
		return 1
	return 0
for _ in range(inp()):
	n = inp()
	a = line()
	l = solve(a)
	if l == 1:
		print('Yes')
	else:
		print('No')


import sys
sys.setrecursionlimit(10 ** 5)

class SegmentTree:

	def __init__(self, data):
		self._default = 0
		self._func = lambda a, b: a + b
		self.data = data
		self._len = len(data)
		self.t = [self._default] * (4 * self._len)
		self.build()

	def build(self, v=1, start=0, end=-1):
		if end == -1:
			end = self._len - 1
		if start == end:
			self.t[v] = self.data[start]
			return
		mid = (start + end) // 2
		self.build(v * 2, start, mid)
		self.build(v * 2 + 1, mid + 1, end)
		self.t[v] = self._default

	def query(self, index, v=1, start=0, end=-1):
		if end == -1:
			end = self._len - 1
		if start == end:
			return self.t[v]
		mid = (start + end) // 2
		if index <= mid:
			return self._func(self.t[v], self.query(index, 2 * v, start, mid))
		else:
			return self._func(self.t[v], self.query(index, 2 * v + 1, mid + 1, end))

	def update_range(self, l, r, new_val, v=1, start=0, end=-1):
		if end == -1:
			end = self._len - 1
		if l > r:
			return self._default
		if l == start and r == end:
			self.t[v] = self._func(self.t[v], new_val)
		else:
			mid = (start + end) // 2
			self.update_range(l, min(r, mid), new_val, v * 2, start, mid)
			self.update_range(max(l, mid + 1), r, new_val, v * 2 + 1, mid + 1, end)
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	while i < n - 1:
		if a[i + 1] < a[i] or a[i + 1] == a[i] + 1:
			i += 1
		else:
			break
	print('Yes' if i == n - 1 else 'No')


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	if n == 1 or n == 2:
		print('Yes')
	else:
		flag = True
		i = n - 2
		c = 1
		k = 1
		while i >= 0:
			if lis[i] + 1 == lis[i + 1]:
				c += 1
			elif lis[i + 1] == k:
				c += 1
				k = c
			else:
				flag = False
				break
			i -= 1
		if flag:
			print('Yes')
		else:
			print('No')


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	res = True
	mn = a[0]
	for i in range(1, n):
		if a[i] == a[i - 1] + 1:
			continue
		if a[i] > mn:
			res = False
			break
		mn = min(a[i], mn)
	print('Yes' if res else 'No')


from itertools import accumulate
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	pos = {val: pos for (pos, val) in enumerate(p)}
	if any(map(lambda i: p[pos[i] + 1] > i + 1 if pos[i] + 1 < len(p) else False, range(1, n + 1))):
		print('No')
	else:
		print('Yes')


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = 0
	for i in range(0, n - 1):
		if arr[i + 1] - arr[i] > 1:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


t = int(input())

def test():
	n = int(input())
	perm = list(map(int, input().split()))
	index = {j: i + 1 for (i, j) in enumerate(perm)}
	end = n
	i = 0
	while i < n:
		i += 1
		if index[i] == end:
			end -= 1
		else:
			c = i
			idx = index[i]
			for j in range(end - idx + 1):
				if perm[j + idx - 1] != c:
					return False
				c += 1
			end = idx - 1
			i = c - 1
	return True
for _ in range(t):
	if test():
		print('Yes')
	else:
		print('No')


t = int(input())

def slv(n, a):
	for i in range(n - 1):
		if a[i] < a[i + 1]:
			if a[i + 1] - a[i] > 1:
				return 'No'
	return 'Yes'
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(slv(n, a))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	vis = set()
	nmin = 1
	f = 0
	while len(vis) != n:
		p = arr.index(nmin)
		vis.add(p)
		nmin = nmin + 1
		p += 1
		while p < n and nmin <= n and (p not in vis):
			if arr[p] != nmin:
				print('NO')
				f = 1
				break
			else:
				nmin += 1
				vis.add(p)
			p += 1
		if f:
			break
	if not f:
		print('YES')


import sys, math
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	ind = -1
	j = n
	flag = True
	for i in range(1, n):
		if not (a[i] - a[i - 1] == 1 or a[i] - a[i - 1] < 0):
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


for test in range(int(input())):
	n = int(input())
	last_break = n + 1
	new_start = None
	current_index = None
	permuatation = [None] + list(map(int, input().split()))
	score = [None for value in permuatation]
	answer = 'Yes'
	for index in range(1, n + 1):
		score[permuatation[index]] = index
	new_start = score[1]
	current_index = score[1] + 1
	for value in range(2, n):
		if current_index == last_break:
			current_index = score[value] + 1
			last_break = new_start
			new_start = score[value]
		elif value == permuatation[current_index]:
			current_index += 1
		else:
			answer = 'No'
	print(answer)


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	flag = 0
	for i in range(n - 1, 0, -1):
		if A[i - 1] == A[i] - 1 or A[i - 1] > A[i]:
			flag = 0
		else:
			flag = 1
			break
	if flag == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for x in range(t):
	n = int(input())
	m = list(map(int, input().split()))
	if n == 1:
		print('Yes')
	for x in range(n - 1):
		if m[x + 1] - m[x] > 1:
			print('No')
			break
		elif x == n - 2:
			print('Yes')


t = int(input())
for i in range(t):
	n = int(input())
	row = [int(g) for g in input().split(' ')]
	can = 1
	prev = row[0]
	start = row[0]
	for i in range(1, len(row)):
		if prev == row[i] - 1:
			prev = row[i]
		elif prev == n:
			n = start - 1
			start = row[i]
			prev = row[i]
		else:
			print('No')
			can = 0
			break
	if can:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	for i in range(n - 1):
		if p[i + 1] - p[i] > 1:
			print('NO')
			break
	else:
		print('YES')


class Solution:

	def solve(self, n, a):
		for i in range(1, n):
			if a[i] > a[i - 1] + 1:
				return 'No'
		return 'Yes'

	def __init__(self):
		test = int(input())
		for t in range(0, test):
			n = int(input())
			a = list(map(int, input().split()))
			print(self.solve(n, a))
Solution()


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
if __name__ == '__main_':
	for _ in range(iinput()):
		(n, k) = rinput()
		a = rlinput()
		peaks = [0] * n
		for i in range(1, n - 1):
			if a[i - 1] < a[i] > a[i + 1]:
				peaks[i] = 1
		for i in range(1, n):
			peaks[i] += peaks[i - 1]
		d = defaultdict(list)
		d[peaks[k - 2]].append(1)
		for i in range(1, n - k + 2):
			d[peaks[i + k - 2] - peaks[i - 1]].append(i + 1)
		mx = max(d.keys())
		print(mx + 1, min(d[mx]))
for _ in range(iinput()):
	n = iinput()
	a = rlinput()
	flag = True
	mxtill = 1
	count = 0
	i = n - 1
	while i > -1:
		j = i
		while i > 0 and a[i - 1] + 1 == a[i]:
			i -= 1
		if i > -1 and a[i] == mxtill:
			mxtill = a[j] + 1
			i -= 1
			continue
		else:
			flag = False
			break
		i -= 1
	print(['No', 'Yes'][flag])


from collections import defaultdict

def solve(num):
	global filled
	flag = True
	while flag:
		pos = mp[num]
		while pos + 1 <= n and count[pos + 1] > 0:
			if perm[pos] == num:
				count[pos + 1] += count[pos]
				count[pos] = 0
				filled += 1
				if filled == n:
					return True
				num += 1
				pos += 1
			else:
				flag = False
				return False
		if filled != n:
			if perm[pos] == num:
				count[pos] = 0
				filled += 1
				num += 1
				if filled == n:
					return True
			else:
				flag = False
				return False
t = int(input())
for _ in range(t):
	n = int(input())
	perm = [0]
	perm.extend(map(int, input().split()))
	(mp, filled) = (defaultdict(int), 0)
	for (i, num) in enumerate(perm):
		if i != 0:
			mp[num] = i
	count = [1] * (n + 1)
	flag = solve(1)
	if flag:
		print('Yes')
	else:
		print('No')


for f in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	poss = 1
	for i in range(n - 1):
		if p[i + 1] > p[i] + 1:
			poss = 0
	if poss == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ans = 1
	for i in range(n - 1):
		if s[i] + 1 < s[i + 1]:
			ans = 0
			break
	print('Yes' if ans else 'No')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	v = 1
	f = 0
	i = n - 1
	while i > -1:
		if l[i] != v:
			k = l[i]
			for j in range(k, v - 1, -1):
				if l[i] != j:
					f = 1
					break
				i -= 1
			if f:
				break
			v = k + 1
		else:
			v += 1
			i -= 1
	print('YNeos'[f::2])


def yo():
	for _ in range(int(input().strip())):
		failed = False
		n = int(input().strip())
		permutation = list(map(int, input().split()))
		location = [0 for _ in range(n + 1)]
		for i in range(n):
			location[permutation[i]] = i
		unfilled = [0, n - 1]
		curr_start = None
		curr_idx = None
		for step in range(1, n + 1):
			if curr_start is None and curr_idx is None:
				given_idx = location[step]
				curr_start = given_idx
				curr_idx = curr_start
			elif curr_idx == unfilled[-1]:
				unfilled[-1] = curr_start - 1
				given_idx = location[step]
				curr_start = given_idx
				curr_idx = curr_start
			else:
				curr_idx += 1
				if curr_idx == location[step]:
					pass
				else:
					print('NO')
					failed = True
					break
		if not failed:
			print('YES')
yo()


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pos = [0 for i in range(n + 1)]
	for i in range(n):
		pos[l[i]] = i + 1
	m = 'F'
	last = n
	flag = True
	for i in range(1, n + 1):
		if m == 'F':
			if pos[i] != last:
				m = pos[i] + 1
			else:
				last -= 1
		elif m != pos[i]:
			flag = False
			break
		else:
			m += 1
			if m > last:
				m = 'F'
				last = n - i
	if flag:
		print('Yes')
	else:
		print('No')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def abs(x):
	return x if x >= 0 else -x

def sumelem(x, start, end):
	sum = 0
	for i in range(start, end + 1):
		sum += x[i]
	return sum
for t in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	flag = 1
	for i in range(n - 1):
		if num[i + 1] > num[i] + 1:
			flag = 0
			break
	print('Yes' if flag == 1 else 'No')


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(fastinput())
while t:
	t -= 1
	n = int(fastinput())
	p = list(map(int, fastinput().split()))
	for i in range(n - 1):
		if p[i + 1] - p[i] > 1:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	q = p[::-1]
	m = q[0]
	flag = True
	for i in range(1, n):
		if q[i] == q[i - 1] - 1:
			continue
		elif q[i] > m:
			m = q[i]
			continue
		else:
			flag = False
		break
	if flag:
		print('Yes')
	else:
		print('No')


import io
import os
import random
from collections import Counter, defaultdict, deque

def solve(N, P):
	groups = [[P[0]]]
	for x in P[1:]:
		if x == groups[-1][-1] + 1:
			groups[-1].append(x)
		else:
			groups.append([x])
	curr = 1
	while groups:
		g = groups.pop()
		if g[0] != curr:
			return 'No'
		curr = g[-1] + 1
	return 'Yes'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	ans = solve(N, P)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	vis = [0 for i in range(n + 1)]
	pos = [-1 for i in range(n + 1)]
	for i in range(n):
		pos[a[i]] = i + 1
	res = [-1 for i in range(n + 1)]
	for i in range(1, n + 1):
		if vis[pos[i]] == 0:
			here = pos[i]
			j = here
			while j <= n and i + j - here <= n:
				if vis[j] == 0:
					vis[j] = 1
					res[j] = i + j - here
					j += 1
				else:
					j = n + 1
					break
	ok = True
	for i in range(n):
		if res[i + 1] is not a[i]:
			ok = False
			break
	if ok:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	fl = 0
	for (i, j) in zip(p[:-1], p[1:]):
		if i <= j and i != j - 1:
			print('NO')
			fl = 1
			break
	if fl != 1:
		print('YES')


from collections import defaultdict
import bisect
import sys
input = sys.stdin.readline

def solve(n, a):
	pos = [0] * (n + 1)
	for (i, aa) in enumerate(a):
		pos[aa] = i
	bef = -1
	tail = n - 1
	ntail = n - 2
	for aa in range(1, n + 1):
		if bef >= 0 and pos[aa] != bef + 1:
			print('No')
			return 0
		elif pos[aa] == tail:
			bef = -1
			tail = ntail
			ntail -= 1
		elif bef == -1:
			bef = pos[aa]
			ntail = pos[aa] - 1
		else:
			bef = pos[aa]
	print('Yes')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		solve(n, a)
main()


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	flag = 0
	for j in range(0, n - 1):
		if s[j + 1] > s[j] + 1:
			flag = 1
	if flag == 0:
		print('Yes')
	else:
		print('No')


tt = int(input())
while tt != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	p = 1
	i = -1
	startin_i = -1
	ending_i = n
	digit = 1
	for i in range(n):
		if list1[i] == 1:
			startin_i = i
			break
	f1 = 0
	while startin_i != 0:
		for j in range(startin_i, ending_i):
			if list1[j] != digit:
				f1 = 1
				break
			else:
				digit += 1
		if f1 == 1:
			print('NO')
			break
		else:
			ending_i = startin_i
			temp = -1
			for j in range(startin_i):
				if list1[j] == digit:
					temp = j
					break
			if temp == -1:
				print('NO')
				f1 = 1
				break
			else:
				startin_i = temp
	if startin_i == 0:
		for j in range(startin_i, ending_i):
			if list1[j] != digit:
				print('NO')
				f1 = 1
				break
			else:
				digit += 1
	if f1 == 0:
		print('YES')
	tt -= 1


def f(arr):
	n = len(arr)
	d = {v: i for (i, v) in enumerate(arr)}
	seen = {n}
	pidx = d[1] - 1
	for i in range(n - 1):
		idx = d[i + 1]
		if idx == pidx + 1:
			if idx + 1 in seen:
				pidx = d[i + 2] - 1
			else:
				pidx = idx
			seen.add(idx)
		else:
			return 'No'
	return 'Yes'
T = int(input())
for case in range(T):
	input()
	arr = [int(i) for i in input().split(' ')]
	print(f(arr))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	ok = True
	for i in range(1, n):
		if p[i - 1] < p[i] and p[i - 1] + 1 != p[i]:
			ok = False
			break
	print('Yes' if ok else 'No')


import sys
numTest = int(input())
sys.setrecursionlimit(20000)

def check(l, num):
	if len(l) == 0:
		return True
	k = 0
	while l[k] != num and k < len(l):
		k += 1
	if all((l[i] == -1 + l[i + 1] for i in range(k, len(l) - 1))):
		return check(l[0:k], num + len(l) - k)
	else:
		return False

def test():
	n = int(input())
	data = list(map(int, input().split(' ')))
	return check(data, 1)
for _ in range(0, numTest):
	print('Yes' if test() else 'No')


from math import *
from copy import *
from heapq import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l):
	n = len(l)
	if n <= 2:
		return 'Yes'
	L = []
	ll = []
	start = 0
	for i in range(n):
		if i == 0:
			ll.append(l[i])
		elif l[i] - ll[-1] == 1:
			ll.append(l[i])
		else:
			L.append([ll, start])
			start = i
			ll = [l[i]]
	L.append([ll, start])
	L = sorted(L)
	zz = []
	for i in range(len(L)):
		zz.append(L[i][1])
	if zz != sorted(zz, reverse=True):
		return 'No'
	else:
		return 'Yes'
T = int(input())
for _ in range(T):
	N = int(stdin.readline())
	l = list(map(int, stdin.readline().rstrip().split()))
	print(solve(l))


t = int(input())
for _ in range(t):
	n = int(input())
	per = [int(i) for i in input().split()]
	flag = True
	cont = 0
	i = 0
	find = 1
	while cont < n:
		if per[i] == find:
			cont += 1
			while i < n - 1:
				cont += 1
				if per[i] + 1 != per[i + 1]:
					flag = False
				del per[i]
				n -= 1
			find = per[i] + 1
			del per[i]
			n -= 1
			i = -1
		i += 1
		if not flag:
			break
	if flag:
		print('Yes')
	else:
		print('No')


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	p = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[p[i]] = i
	vis = [False] * n
	for i in range(n):
		j = d[i + 1] + 1
		ok = True
		vis[j - 1] = True
		while j < n and vis[j] == False:
			if p[j] != p[j - 1] + 1:
				ok = False
				break
			vis[j] = True
			j += 1
		if not ok:
			break
	if ok:
		print('Yes')
	else:
		print('No')


def is_ok(perm, n):
	if len(perm) != n:
		return False
	if len(set(perm)) != n:
		return False
	ppos = [0] * n
	for (i, x) in enumerate(perm):
		ppos[x] = i
	sim = [None] * n
	r = list(range(n))
	cnt = [1] * n
	maxcnt = 1
	nxt = None
	for i in range(n):
		chosen = ppos[i]
		if nxt is not None and chosen != nxt:
			return False
		if sim[chosen] is not None:
			return False
		sim[chosen] = i
		if chosen < n - 1 and sim[chosen + 1] is None:
			nxt = chosen + 1
		else:
			nxt = None
	return True
TC = int(input())
for _ in range(TC):
	n = int(input())
	perm = list(map(int, input().split()))
	for i in range(n):
		perm[i] -= 1
	print('Yes' if is_ok(perm, n) else 'No')


def check(i, j):
	for k in range(i + 1, j + 1):
		if a[k] == a[k - 1] + 1:
			continue
		return 0
	return 1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pos = [0] * n
	for i in range(n):
		pos[a[i] - 1] = i
	fl = 0
	if not check(pos[0], n - 1):
		fl = 1
	x = n - pos[0] + 1
	prev = pos[0] - 1
	while prev != -1:
		if not check(pos[x - 1], prev):
			fl = 1
			break
		last = prev + 0
		prev = pos[x - 1] - 1
		x = x + last - pos[x - 1] + 1
	if fl:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	f = 1
	a = list(map(int, input().split()))
	for i in range(1, n):
		if not (a[i] - a[i - 1] == 1 or a[i] - a[i - 1] < 0):
			f = 0
			break
	if f == 0:
		print('NO')
	else:
		print('YES')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		n = N()
		arr = RLL()
		dic = {v: i for (i, v) in enumerate(arr)}
		rec = [1] * n
		ma = 1
		for i in range(1, n + 1):
			p = dic[i]
			if rec[p] != ma:
				print('No')
				break
			if p + 1 < n and rec[p + 1] != 0:
				rec[p + 1] += 1
				ma = max(ma, rec[p + 1])
			else:
				ma = 1
			rec[p] = 0
		else:
			print('Yes')
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = 'YES'
	if n == 1 or n == 2:
		print('YES')
	else:
		m = n
		x = n
		j = 0
		while j < n - 1:
			if l[j] + 1 != l[j + 1]:
				if l[j] == m:
					pass
				elif j == 0:
					if l[j] != n:
						ans = 'NO'
				elif l[j + 1] < m:
					ans = 'NO'
			x = min(x, l[j])
			if l[j] == m:
				m = x - 1
			j += 1
		print(ans)


import sys

def noop(*object):
	return

def main():
	T = read_int()
	for case_idx in range(T):
		ans = solve_case()
		sys.stdout.write('{}\n'.format(ans))

def solve_case():
	n = read_int()
	p = read_int_list()
	is_now_determined = False
	end = n
	max_can_use = n
	next_num_should_be = None
	for i in range(n):
		if not is_now_determined:
			if p[i] > max_can_use:
				return 'No'
			is_now_determined = True
			next_num_should_be = p[i] + 1
			max_can_use = min(max_can_use, p[i] - 1)
		else:
			if p[i] != next_num_should_be:
				return 'No'
			next_num_should_be += 1
		if next_num_should_be > end:
			is_now_determined = False
			next_num_should_be = None
			end = max_can_use
	return 'Yes'

def read_str():
	return input()

def read_int():
	return int(input())

def read_str_list():
	return input().split(' ')

def read_int_list():
	return list(map(int, input().split(' ')))

def read_lines(n, read_func):
	return [read_func() for _ in range(n)]

def list_to_str(l, sep=' '):
	return sep.join(map(str, l))
l2s = list_to_str

def make_list(shape, value=None):
	if len(shape) == 1:
		return [value] * shape[0]
	return [make_list(shape[1:], value) for _ in range(shape[0])]
sys.setrecursionlimit(1000000)
main()


for _ in range(int(input())):
	n = int(input())
	aa = list(map(int, input().split()))
	ok = True
	d = {aa[i]: i for i in range(n)}
	upper = n - 1
	start = 1
	for i in range(1, n + 1):
		if d[i] > upper:
			ok = False
			break
		if d[i] == upper:
			upper = d[start] - 1
			start = i + 1
			continue
		if i == start:
			continue
		if d[i] == d[i - 1] + 1:
			continue
		else:
			ok = False
			break
	print('Yes' if ok else 'No')


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for t in range(test):
		n = int(input())
		l = [int(i) for i in input().split(' ')]
		flag = True
		for i in range(n - 1):
			if l[i + 1] - l[i] > 1:
				flag = False
				break
		if flag:
			print('Yes')
		else:
			print('No')
main()


def solve():
	new = [-1] * n
	inds = [-1] * n
	for i in range(n):
		inds[p[i] - 1] = i
	counter = 0
	pos = inds[0]
	while 1:
		if new[pos] == -1:
			new[pos] = counter + 1
		else:
			print('No')
			return
		counter += 1
		if counter == n:
			break
		if pos + 1 < n and new[pos + 1] == -1:
			pos = pos + 1
		else:
			pos = inds[counter]
	if new == p:
		print('Yes')
	else:
		print('No')
	return
t = int(input())
for i in range(1, t + 1):
	n = int(input())
	p = [int(s) for s in input().split(' ')]
	solve()


def possible(ar):
	m = min(ar)
	x = ar.index(m)
	if ar[-1] == m:
		i = 0
		while len(ar) > 0 and ar[-1] == m + i:
			ar.pop()
			i += 1
		if len(ar) == 0:
			return True
		m = min(ar)
		x = ar.index(m)
	if not all((ar[i] == ar[i - 1] + 1 for i in range(x + 1, len(ar)))):
		return False
	else:
		if x == 0:
			return True
		return possible(ar[:x])
for _ in range(int(input())):
	N = int(input())
	ar = list(map(int, input().split()))
	if possible(ar):
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.buffer.readline
T = int(input())

def find(x):
	if par[x] < 0:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

def unite(x, y):
	x = find(x)
	y = find(y)
	if x == y:
		return False
	else:
		if par[x] > par[y]:
			(x, y) = (y, x)
		par[x] += par[y]
		par[y] = x
		return True

def same(x, y):
	return find(x) == find(y)

def size(x):
	return -par[find(x)]
for testcase in range(T):
	n = int(input())
	p = list(map(int, input().split()))
	par = [-1] * n
	q = [0] * n
	for i in range(n):
		q[p[i] - 1] = i
	r = list(range(n))
	c = [1] * n
	ma = 1
	flag = True
	for i in range(n - 1):
		k = q[i]
		if k < n - 1:
			val = r[find(k + 1)]
			unite(k, k + 1)
			r[find(k)] = val
		else:
			r[find(k)] = -1
		rr = r[find(k)]
		if rr != -1:
			c[rr] += c[k]
			if c[rr] > ma:
				ma = c[rr]
		if ma == c[k]:
			c[k] = 0
			ma = max(c)
		c[k] = 0
		if ma != c[q[i + 1]]:
			flag = False
			break
	if flag:
		print('Yes')
	else:
		print('No')


import sys
readline = sys.stdin.readline
for _ in range(int(input())):
	n = int(readline())
	a = list(map(int, readline().split()))
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			if a[i] + 1 != a[i + 1]:
				sys.stdout.write('No\n')
				break
	else:
		sys.stdout.write('Yes\n')


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	has = [0] * (n + 1)
	m = n
	i = 0
	c = 1
	while i < n:
		aa = lis[i]
		tmp = lis[i]
		while i < n and aa == lis[i]:
			aa += 1
			i += 1
		aa -= 1
		if aa != m:
			print('No')
			c = 0
			break
		m = tmp - 1
	if c:
		print('Yes')


t = int(input())
while t > 0:
	n = int(input())
	ar = list(map(int, input().split()))
	f = 0
	for i in range(0, n - 1):
		if ar[i + 1] - ar[i] == 1:
			continue
		elif ar[i + 1] - ar[i] > 1:
			f = 1
			print('No')
			break
	if f == 0:
		print('Yes')
	t -= 1


import sys
input = sys.stdin.readline
import collections as cc
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	f = cc.defaultdict(int)
	for i in range(n):
		f[l[i]] = i
	ans = 'Yes'
	for i in range(1, n):
		if f[i] > f[i + 1] or f[i] + 1 == f[i + 1]:
			ans = 'Yes'
		else:
			ans = 'No'
			break
	print(ans)


T = int(input())
for t in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	end = n - 1
	index = [-1] * (n + 1)
	for i in range(n):
		index[A[i]] = i
	i = 1
	flag = 0
	while i < n:
		pos = index[i]
		temppos = pos
		for j in range(pos, end + 1):
			if A[pos] != i:
				flag = 1
				break
			i += 1
			pos += 1
		if flag == 1:
			break
		end = temppos - 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
out = sys.stdout.write
for t in range(int(data())):
	(n,) = mdata()
	P = list(mdata())
	flag = True
	for i in range(n - 1):
		if P[i + 1] - P[i] > 1:
			flag = False
			break
	if flag == True:
		print('Yes')
	else:
		print('No')


from sys import stdin
t = int(stdin.readline())
output = []
for tc in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	curr = 1
	next = a[-1] + 1
	for i in range(n - 2, -1, -1):
		if a[i] + 1 == a[i + 1]:
			continue
		elif a[i + 1] != curr:
			output.append('No')
			break
		else:
			curr = next
			next = a[i] + 1
	else:
		output.append('Yes')
print('\n'.join(output))


t = int(input())
while t > 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	d = {}
	for i in range(n):
		d[a[i]] = i
	b = [0] * n
	b[d[1]] = 1
	for i in range(2, n + 1):
		if d[i - 1] == n - 1 or b[d[i - 1] + 1] != 0:
			b[d[i]] = 1
		elif b[d[i - 1] + 1] == 0 and d[i] == d[i - 1] + 1:
			b[d[i]] = 1
		else:
			print('No')
			break
	else:
		print('Yes')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	flag = True
	for i in range(n - 1, 0, -1):
		if a[i] - a[i - 1] > 1:
			print('No')
			flag = False
			break
	if flag:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	i = p.index(1)
	nb = 1
	t = 0
	j = n
	s = i
	l = 0
	while i < j and l < n:
		if p[i] != nb:
			t = 1
		l += 1
		nb += 1
		i += 1
		if i == j and l < n:
			j = s
			i = p.index(nb)
			s = i
	ans = ['YES', 'NO']
	print(ans[t])


t = int(input())
for hh in range(0, t):
	n = int(input())
	a = [int(x) for x in input().split()]
	flag = 0
	for i in range(0, n - 1):
		if a[i] < a[i + 1]:
			if a[i + 1] != a[i] + 1:
				flag = 1
	if flag == 1:
		print('No')
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	dp = [0] * (n + 1)
	arr = [-1] * (n + 1)
	arr[0] = 0
	a = list(map(int, input().split()))
	for i in range(n):
		dp[a[i]] = i + 1
	var = 1
	while var <= n:
		p = dp[var]
		arr[p] = var
		var += 1
		i = p + 1
		while i < n and arr[i] == -1:
			arr[i] = var
			var += 1
			i += 1
	bl = 0
	for i in range(n):
		if a[i] != arr[i + 1]:
			bl = 1
			break
	if bl == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	P = list(map(int, input().split()))
	current = [-1] * N
	count = [1] * N
	maxCnt = 1
	flag = True
	indexes = [0] * N
	for i in range(N):
		indexes[P[i] - 1] = i
	for i in range(1, N):
		idx = indexes[i - 1]
		if count[idx] != maxCnt:
			print('No')
			flag = False
			break
		else:
			current[idx] = i
			if count[idx] == maxCnt:
				maxCnt = 1
			for j in range(idx + 1, N):
				if count[j] >= 1:
					count[j] += count[j - 1]
					if count[j] > maxCnt:
						maxCnt = count[j]
					break
			count[idx] = 0
	if flag:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[p[i]] = i + 1
	l = n
	(k, f) = (0, d[1])
	for i in range(1, n):
		if d[i] != l:
			if d[i + 1] != d[i] + 1:
				k = 1
				break
		else:
			l = f - 1
			f = d[i + 1]
	if k == 0:
		print('YES')
	else:
		print('NO')


from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()

def solve(p):
	n = len(p)
	d = [0] * (n + 1)
	for i in range(n):
		d[p[i]] = i
	cur = 1
	start = d[cur]
	end = n
	while True:
		for i in range(start, end):
			if p[i] != cur:
				return 'No'
			cur += 1
		if cur > n:
			break
		end = start
		start = d[cur]
	return 'Yes'
t = iint()
for _ in range(t):
	n = iint()
	p = ilist()
	print(solve(p))


import math
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	a = [0 for i in range(n + 1)]
	for i in range(n):
		a[li[i]] = i
	flag = 0
	vis = [0 for i in range(n)]
	j = 1
	while flag == 0 and j <= n:
		pp = j
		for i in range(a[pp], n):
			if li[i] != j and vis[i] == 0:
				flag = 1
				break
			else:
				if vis[i] == 1:
					break
				vis[i] = 1
				j += 1
	if flag == 0:
		print('Yes')
	else:
		print('No')


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
for _ in range(I()[0]):
	n = int(input())
	a = [int(i) for i in input().split()]
	f = n
	ans = 'Yes'
	for i in range(n - 1):
		if a[i] == f:
			f = n - i - 1
		elif a[i] + 1 == a[i + 1]:
			continue
		else:
			ans = 'No'
			break
	print(ans)


def valid(a, i):
	if len(a) == 0:
		return True
	for (j, e) in reversed(tuple(enumerate(a))):
		if e == i + 1:
			return valid(a[:j], a[-1])
		if e != a[j - 1] + 1:
			return False
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if valid(a, 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	last_start = l[0]
	prev = l[0]
	for j in l[1:]:
		if j == prev + 1:
			prev = j
			continue
		prev = j
		if j >= last_start:
			print('No')
			break
		last_start = j
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	low = 1
	possible = True
	i = n - 1
	while possible and i >= 0:
		start = i - (p[i] - low)
		end = i + 1
		if start < 0:
			print('No')
			break
		if p[start:end] != list(range(low, p[i] + 1)):
			print('No')
			break
		low = p[i] + 1
		i = start - 1
	else:
		print('Yes')


t = int(input())
res = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = 'Yes'
	for i in range(1, n):
		if arr[i] - arr[i - 1] > 1:
			temp = 'No'
			break
	res.append(temp)
for r in res:
	print(r)


import os

def pp(input):
	n_test = int(input())
	for i in range(n_test):
		input()
		prev = None
		for k in map(int, input().split()):
			if prev is not None and k - prev > 1:
				print('No')
				break
			prev = k
		else:
			print('Yes')
if 'paalto' in os.getcwd():
	from string_source import string_source
	s1 = string_source('5\n5\n2 3 4 5 1\n1\n1\n3\n1 3 2\n4\n4 2 3 1\n5\n1 5 2 4 3\n')
	pp(s1)
else:
	pp(input)


from sys import setrecursionlimit
from collections import deque
import heapq
import functools

def IntInput():
	return int(input())

def M_IntInput():
	return map(int, input().split())

def M_StrInput():
	return map(int, input().split())

def IntArrayInput():
	return list(map(int, input().split()))

def modInverse(p, a, m):
	return p % m * pow(a % m, m - 2, m) % m

def compare(item1, item2):
	return item2[0] - item1[0] if item1[0] != item2[0] else item1[1] - item2[1]

def DFS(s, n, paths, answer):
	visited = [False] * (n + 1)
	stack = []
	stack.append(s)
	visited[s] = True
	DFSArray = []
	while stack:
		s = stack.pop()
		DFSArray.append(s)
		flag = 0
		for i in paths[s]:
			if visited[i] == False:
				flag = 1
				stack.append(i)
				visited[i] = True
		if not flag:
			answer[s - 1][1] = 0
	while DFSArray != []:
		s = DFSArray.pop()
		if answer[s - 1][1] < 0:
			answer[s - 1][1] = 0
			for i in paths[s]:
				if answer[i - 1][1] >= 0:
					answer[s - 1][1] += answer[i - 1][1] + 1
	return answer

def BFS(s, n, paths, answer):
	visited = [False] * (n + 1)
	answer[s - 1][0] = 0
	queue = deque()
	queue.append(s)
	visited[s] = True
	while queue:
		s = deque.popleft(queue)
		for i in paths[s]:
			if visited[i] == False:
				queue.append(i)
				answer[i - 1][0] = answer[s - 1][0] + 1
				visited[i] = True
	return answer
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

def fun(array, n):
	start = 1
	ans = True
	while ans and len(array) > 0:
		while array != [] and array[-1] == start:
			array.pop()
			start += 1
		if array == []:
			break
		newstart = array[-1] + 1
		while len(array) > 1 and array[-1] != start:
			if array[-1] == array[-2] + 1:
				array.pop()
			else:
				return 'No'
				break
		if array != [] and array[-1] == start:
			array.pop()
			start = newstart
	return 'Yes'
for _ in range(int(input())):
	n = int(input())
	print(fun(IntArrayInput(), n))


for _ in range(int(input())):
	N = int(input())
	P = list(map(int, input().split()))
	i = 0
	count = N
	a = []
	temp = 0
	while i < N:
		for j in range(P[i], count + 1):
			a.append(j)
			if a[i] != P[i]:
				temp = 1
				break
			count -= 1
			i = i + 1
		if temp == 1:
			break
	if temp == 1:
		print('No')
	else:
		print('Yes')


t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	ch = 1
	for i in range(n - 1):
		if l[i + 1] > l[i] + 1:
			ch = 0
			break
	if ch:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	rv = 1
	prev = -1
	f = 0
	for (i, c) in enumerate(p):
		if prev + 1 != c:
			if prev != -1 and f != n - i + 1:
				print('No')
				break
			f = c
		prev = c
	else:
		print('Yes')


import sys

class CNastyaAndStrangeGenerator:

	def solve(self, tc=0):
		from sys import maxsize
		INT_MIN = -maxsize

		def construct_segment_tree(a: list, n: int):
			for i in range(n):
				segtree[n + i] = a[i]
			for i in range(n - 1, 0, -1):
				segtree[i] = max(segtree[2 * i], segtree[2 * i + 1])

		def update(pos: int, value: int, n: int):
			pos += n
			segtree[pos] = value
			while pos > 1:
				pos //= 2
				segtree[pos] = max(segtree[2 * pos], segtree[2 * pos + 1])

		def range_query(left: int, right: int, n: int) -> int:
			left += n
			right += n
			ma = INT_MIN
			while left < right:
				if left & 1:
					ma = max(ma, segtree[left])
					left += 1
				if right & 1:
					right -= 1
					ma = max(ma, segtree[right])
				left //= 2
				right //= 2
			return ma
		for _ in range(int(input())):
			n = int(input())
			p = [int(_) for _ in input().split()]
			pos = [0] * (n + 1)
			for (i, x) in enumerate(p):
				pos[x] = i + 1
			nxt = {i: i + 1 for i in range(1, n + 1)}
			bef = {i: i - 1 for i in range(1, n + 1)}
			cnt = [1] * (n + 1)
			cnt[0] = 0
			segtree = [0] * (2 * (n + 1))
			construct_segment_tree(cnt, n + 1)
			for i in range(1, n + 1):
				cntposi = range_query(pos[i], pos[i] + 1, n + 1)
				if cntposi == range_query(0, n + 1, n + 1):
					if nxt[pos[i]] <= n:
						update(nxt[pos[i]], range_query(nxt[pos[i]], nxt[pos[i]] + 1, n + 1) + cntposi, n + 1)
					update(pos[i], 0, n + 1)
					nxt[bef[pos[i]]] = nxt[pos[i]]
					bef[nxt[pos[i]]] = bef[pos[i]]
				else:
					print('No')
					break
			else:
				print('Yes')
solver = CNastyaAndStrangeGenerator()
input = sys.stdin.readline
solver.solve()


import io, os
import sys
from atexit import register
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())

def print(s):
	sys.stdout.write((str(s) + '\n').encode())

def getPeaks(a):
	res = set()
	for i in range(1, len(a) - 1):
		if a[i] > a[i - 1] and a[i] > a[i + 1]:
			res.add(i)
	return res
t = nextInt()
for _ in range(t):
	n = nextInt()
	a = [nextInt() for i in range(n)]
	pos = {a[i]: i for i in range(len(a))}
	res = True
	filled = [False] * n
	for curNum in range(1, len(a) + 1):
		if not res:
			break
		curPos = pos[curNum]
		if filled[curPos]:
			continue
		filled[curPos] = True
		for j in range(curPos + 1, len(a)):
			if filled[j]:
				break
			if a[j] != curNum + j - curPos:
				res = False
				break
			filled[j] = True
	print('Yes' if res else 'No')


tests = input()
for testNum in range(int(tests)):
	n = int(input())
	perm = [int(i) for i in input().split(' ')]
	submitted = [-1] * n
	position = [0] * n
	for each in range(len(perm)):
		position[perm[each] - 1] = each
	valid = True
	for i in range(len(position) - 1):
		if position[i + 1] != position[i] + 1 and position[i + 1] > position[i]:
			valid = False
			print('No')
			break
	if valid:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = a[0]
	b = []
	for i in range(1, n):
		if a[i] != a[i - 1] + 1:
			b.append(l)
			l = a[i]
	for i in range(1, len(b)):
		if b[i - 1] < b[i]:
			print('No')
			break
	else:
		print('Yes')


from collections import Counter
import math
mod = 10 ** 9 + 7
for i in range(int(input())):
	n = int(input())
	flag = 0
	d = {}
	arr = [int(i) for i in input().split()]
	m = 0
	vis = [0 for i in range(n + 1)]
	for i in range(1, n + 1):
		d[arr[i - 1]] = i
	vis[d[1]] = 1
	for i in range(2, n + 1):
		if d[i - 1] + 1 > n:
			vis[d[i]] = 1
		elif d[i - 1] + 1 != d[i] and vis[d[i - 1] + 1] == 0:
			print('NO')
			flag = 1
			break
		else:
			vis[d[i]] = 1
	if flag == 0:
		print('YES')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		ok = True
		for (b, c) in zip(a, a[1:]):
			if b + 1 < c:
				ok = False
				break
		rr.append(Yes(ok))
	return JA(rr, '\n')
print(main())


from collections import deque
for _ in range(int(input())):
	n = int(input())
	vals = [0] * (n + 1)
	for (ind, i) in enumerate(map(int, input().split())):
		vals[i] = ind
	start = vals[1]
	right = start
	val = 1
	can = True
	while True:
		if val == n:
			break
		ind = vals[val + 1]
		if ind != start + 1 and (not (start == n - 1 or (ind < start and start + 1 >= right))):
			can = False
			break
		start = ind
		val += 1
		right = min(right, start)
	print('Yes' if can else 'No')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	arr = [False] * n
	for i in range(n):
		d[a[i]] = i
	now = d[1]
	arr[now] = True
	flag = 0
	for i in range(2, n + 1):
		pos = d[i]
		if now + 1 < n and arr[now + 1] == False:
			if pos == now + 1:
				arr[now + 1] = True
			else:
				flag = 1
				break
		else:
			arr[pos] = True
		now = pos
	if flag:
		print('No')
	else:
		print('Yes')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def intersection(l1, r1, l2, r2):
	if l1 <= l2:
		if l2 <= r1:
			return True
		else:
			return False
	elif l1 <= r2:
		return True
	else:
		return False

def s(n):
	return n * (n + 1) // 2
t = I()
for _ in range(t):
	n = I()
	d = defaultdict(int)
	l = L()
	v = [0] * n
	le = 0
	r = n - 1
	for i in range(n):
		d[l[i] - 1] = i
	i = 0
	w = 0
	k = 0
	while i < n:
		if d[i] == r:
			k += 1
			v[r] = 1
			r -= 1
		else:
			r = d[i] - 1
			for j in range(d[i], n):
				if v[j] == 0:
					if l[j] - 1 != k:
						print('No')
						w = 1
						break
					v[j] = 1
					k += 1
			i = k - 1
			if w == 1:
				break
		i += 1
	if w == 0:
		print('Yes')


t = int(input())
for _ in range(0, t):
	n = int(input())
	ar = [int(x) for x in input().split()]

	def solve(ar, n):
		f = 0
		for i in range(0, n - 1):
			if ar[i] < ar[i + 1]:
				if ar[i + 1] != ar[i] + 1:
					f = 1
		return f
	x = solve(ar, n)
	if x == 1:
		print('No')
	else:
		print('Yes')


a = int(input())
for i in range(a):
	x = int(input())
	z = list(map(int, input().split()))
	ans = [0 for i in range(len(z))]
	for i in range(len(z)):
		ans[z[i] - 1] = i + 1
	end = len(z)
	flag = 0
	glag = 0
	temp = 0
	if ans[0] == end:
		flag = 1
		end = end - 1
	else:
		temp = ans[0] - 1
	for i in range(1, len(ans)):
		if flag == 0:
			if ans[i] != ans[i - 1] + 1:
				glag = 1
				break
			elif ans[i] == end:
				flag = 1
				end = temp
		elif ans[i] == end:
			flag = 1
			end = end - 1
		else:
			flag = 0
			temp = ans[i] - 1
	if glag == 1:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.readline
t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[l[i]] = i + 1
	arr = [1] * (n + 1)
	flag = True
	current = 1
	pos = d[current]
	arr[pos] = 0
	current += 1
	pos += 1
	for i in range(n - 1):
		if pos > n or arr[pos] == 0:
			pos = -1
		if pos != -1:
			if arr[pos] == 1 and pos == d[current]:
				arr[pos] = 0
				current += 1
				pos += 1
			else:
				flag = False
				break
		elif arr[d[current]] == 1:
			arr[d[current]] = 0
			if arr[d[current] + 1] == 1:
				pos = d[current] + 1
			else:
				pos = -1
			current += 1
	if flag == True:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
input = stdin.buffer.readline
t = int(input())
while t > 0:
	n = int(input())
	pos = []
	for i in range(n + 1):
		pos.append(0)
	a = [int(x) for x in input().split()]
	for i in range(n):
		pos[a[i]] = i + 1
	l = pos[1]
	flag = 0
	for i in range(2, n + 1):
		if pos[i - 1] == n:
			n = l - 1
			l = pos[i]
		elif pos[i] == pos[i - 1] + 1:
			continue
		else:
			flag = 1
			break
	if flag == 0:
		print('Yes')
	else:
		print('No')
	t -= 1


import collections
import heapq
t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = {}
	for i in range(len(a)):
		pos[a[i]] = i
	flag = True
	index = n
	smallestIndex = pos[1]
	prev = pos[1]
	for i in range(2, n + 1):
		if prev + 1 < index:
			if pos[i] == prev + 1:
				prev += 1
			else:
				print('No')
				flag = False
				break
		else:
			index = smallestIndex
			smallestIndex = pos[i]
			prev = pos[i]
	if flag:
		print('Yes')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().strip().split()))
	if n == 1:
		print('Yes')
	else:
		f = 0
		for j in range(1, n):
			if l[j] - l[j - 1] == 1:
				continue
			elif l[j] < l[j - 1]:
				continue
			else:
				f = 1
				break
		if f == 0:
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	N = int(input())
	Indexes = [0] * (N + 1)
	Check = [False] * (N + 1)
	Checked = [False] * (N + 1)
	Numbers = list(map(int, input().split()))
	for i in range(N):
		Indexes[Numbers[i]] = i
	CheckTotal = False
	Number = 1
	while Number != N + 1:
		if Checked[Number] == False:
			Checked[Number] = True
			Check[Indexes[Number]] = True
			ThisIndex = Indexes[Number] + 1
			while Check[ThisIndex] == False and ThisIndex < N and (Number < N + 1):
				Number += 1
				if Numbers[ThisIndex] != Number:
					CheckTotal = True
					break
				else:
					Checked[Number] = True
					Check[ThisIndex] = True
				ThisIndex += 1
		Number += 1
		if CheckTotal:
			break
	if CheckTotal:
		print('NO')
	else:
		print('YES')


import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	n = INT()
	p = LIST()
	flag = 0
	r = []
	for i in range(n):
		r.append(i)
	cnt = [1] * n
	boolCheck = [False] * n
	numToIdx = {}
	for i in range(n):
		numToIdx[p[i]] = i
	occOrNot = [False] * n
	for i in range(1, n + 1):
		idx = numToIdx[i]
		occOrNot[idx] = True
		for j in range(idx + 1, n):
			i += 1
			if occOrNot[j] == True:
				break
			if p[j] - p[j - 1] != 1:
				flag = 1
				break
			occOrNot[j] = True
	if flag == 1:
		print('No')
	else:
		print('Yes')
	t -= 1


t = int(input())
for dobpt in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	answer = 'Yes'
	for i in range(n - 1):
		if p[i + 1] > p[i] and p[i + 1] != p[i] + 1:
			answer = 'No'
	print(answer)


t = int(input())
for _ in range(t):
	n = int(input())
	P = list(map(int, input().strip().split()))
	indexs = {P[i]: i for i in range(n)}
	P.append(0)
	t = 1
	k = False
	while True:
		i = indexs[t]
		while P[i] != 0:
			if P[i + 1] != 0:
				if P[i + 1] != P[i] + 1:
					k = True
					break
				else:
					P[i] = 0
				t += 1
				i += 1
			else:
				P[i] = 0
				t += 1
				break
		if k == True or t == n + 1:
			break
	if k == True:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	o = [0 for i in range(n)]
	s = 1
	failed = False
	while not failed and s <= n:
		i = arr.index(s)
		o[i] = 1
		s += 1
		i += 1
		while i < n and o[i] == 0:
			if arr[i] != s:
				failed = True
				break
			else:
				o[i] = 1
				s += 1
				i += 1
	if failed:
		print('No')
	else:
		print('Yes')


from sys import stdin, stdout

def main():
	INVALID = -100
	rows = stdin.read().split('\n')
	T = int(rows[0])
	for m in range(1, T + 1):
		n = int(rows[2 * m - 1])
		p = list(map(int, rows[2 * m].split(' ')))
		start = INVALID
		nxt = INVALID
		end = n
		good = True
		for j in p:
			if start == INVALID:
				if j == end:
					end = j - 1
					start = INVALID
					nxt = INVALID
					continue
				start = j
				nxt = j + 1
				continue
			if nxt == j:
				if j == end:
					end = start - 1
					start = INVALID
					nxt = INVALID
					continue
				nxt = j + 1
				continue
			good = False
			break
		if good:
			print('Yes')
		else:
			print('No')
main()


import sys
input = sys.stdin.buffer.readline

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		P = list(map(int, input().split()))
		d = {}
		for (i, p) in enumerate(P):
			d[p - 1] = i

		def segfunc(x, y):
			if x >= y:
				return x
			else:
				return y

		def init(init_val):
			for i in range(n):
				seg[i + num - 1] = init_val[i]
			for i in range(num - 2, -1, -1):
				seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

		def update(k, x):
			k += num - 1
			seg[k] = x
			while k:
				k = (k - 1) // 2
				seg[k] = segfunc(seg[2 * k + 1], seg[2 * k + 2])

		def query(p, q):
			if q <= p:
				return ide_ele
			p += num - 1
			q += num - 2
			res = ide_ele
			while q - p > 1:
				if p & 1 == 0:
					res = segfunc(res, seg[p])
				if q & 1 == 1:
					res = segfunc(res, seg[q])
					q -= 1
				p = p // 2
				q = (q - 1) // 2
			if p == q:
				res = segfunc(res, seg[p])
			else:
				res = segfunc(segfunc(res, seg[p]), seg[q])
			return res
		ide_ele = -1
		num = 2 ** (n - 1).bit_length()
		seg = [ide_ele] * 2 * num
		A = [1] * n
		init(A)
		flag = True
		for i in range(n):
			idx = d[i]
			v1 = query(idx, idx + 1)
			if v1 != query(0, n):
				flag = False
			if idx != n - 1:
				v2 = query(idx + 1, idx + 2)
				if v2 != 0:
					update(idx + 1, v1 + v2)
			update(idx, 0)
		if flag:
			print('Yes')
		else:
			print('No')
main()


def fun(a, n):
	if len(a) == 0:
		print('YES')
		return
	elif a[-1] == n:
		i = len(a) - 1
		while a[i] == n:
			n += 1
			i -= 1
		fun(a[:i + 1], n)
	else:
		if a[a.index(n) + 1:] != list(range(n + 1, n + len(a) - a.index(n))):
			print('NO')
			return
		fun(a[:a.index(n)], n + len(a) - a.index(n))
	return
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	fun(a, 1)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	st = l[0]
	start = l[0]
	end = n + 1
	i = 0
	while i < n:
		if l[i] == st and st != end:
			st += 1
		elif st == end:
			end = start
			st = l[i]
			start = l[i]
			i -= 1
		else:
			print('No')
			break
		i += 1
	else:
		print('Yes')


import sys
input = sys.stdin.readline
from collections import *

def check(l):
	a = l[0]
	for i in range(len(l)):
		if l[i] != a + i:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	now = []
	flag = True
	for i in range(n - 1):
		now.append(p[i])
		if p[i] > p[i + 1]:
			flag &= check(now)
			now = []
	now.append(p[-1])
	flag &= check(now)
	if flag:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	r = 'Yes'
	for i in range(0, n - 1):
		if a[i + 1] > a[i] + 1:
			r = 'No'
	print(r)


def process():
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	head = n
	minx = n
	while i < n - 1:
		if a[i] + 1 == a[i + 1]:
			minx = min(minx, a[i])
			i += 1
		elif a[i] == head:
			minx = min(minx, a[i])
			i += 1
			head = minx - 1
		else:
			return False
	return True
for _ in range(int(input())):
	if process():
		print('Yes')
	else:
		print('No')


import sys, inspect
ints = (int(x) for x in sys.stdin.read().split())
ntc = next(ints)
for tc in range(1, ntc + 1):
	n = next(ints)
	p = [next(ints) for i in range(n)]
	h = [p[i] for i in range(n) if i == 0 or p[i - 1] + 1 != p[i]]
	print('Yes' if sorted(h) == h[::-1] else 'No')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = 1
	for i in range(n - 1, 0, -1):
		if arr[i] - 1 > arr[i - 1]:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


s = []
for jjkj in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	if n == 1:
		s.append('yes')
	else:
		p = x[0]
		for i in range(1, n):
			if x[i] > p:
				if x[i] == p + 1:
					p = x[i]
				else:
					s.append('no')
					break
			else:
				p = x[i]
		if len(s) != jjkj + 1:
			s.append('yes')
for i in s:
	print(i)


cases = int(input())
for t in range(cases):
	n = int(input())
	l = list(map(int, input().split()))
	i = 1
	poss = True
	vu = set()
	while i < n:
		ind = l.index(i)
		vu.add(ind)
		while ind + 1 < n and ind + 1 not in vu and (l[ind + 1] == l[ind] + 1):
			ind += 1
			vu.add(ind)
		if ind + 1 < n and ind + 1 not in vu and (l[ind + 1] != l[ind] + 1) and (l[ind] < n):
			poss = False
			break
		i = l[ind] + 1
	if poss:
		print('Yes')
	else:
		print('No')


from _collections import deque
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ans = 'Yes'
	min_num = 0
	max_num = ar[-1]
	i = n - 1
	kek = 0
	while i > 0:
		if ar[i] - 1 == ar[i - 1]:
			kek = 0
		elif ar[i] == min_num + 1:
			min_num = max_num
			max_num = ar[i - 1]
		else:
			ans = 'No'
		i -= 1
	print(ans)


t = int(input())
for test in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	index = [0 for i in range(n + 1)]
	for i in range(n):
		index[arr[i]] = i
	visited = [False for i in range(n)]
	lasti = index[1]
	flag = True
	for i in range(2, n + 1):
		if index[i] > index[i - 1]:
			if index[i] != index[i - 1] + 1:
				flag = False
	if flag:
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def check(n, A):
	index = n - 1
	look_for = 1
	while index >= 0:
		t = A[index] + 1
		while index > 0 and A[index - 1] == A[index] - 1:
			index -= 1
		if A[index] != look_for:
			return False
		look_for = t
		index -= 1
	return True

def from_file(f):
	return f.readline
t = inp()
for _ in range(t):
	n = inp()
	A = inlt()
	if check(n, A):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	out = 'Yes'
	for i in range(N - 1):
		if a[i + 1] > a[i] + 1:
			out = 'No'
			break
	print(out)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
from io import BytesIO
for t in range(int(input())):
	n = int(input())
	array = [0] + input().split()
	isVisited = [0] + [0] * (n + 1)
	position = [0] + [0] * (n + 1)
	for i in range(n + 1):
		array[i] = int(array[i])
		position[array[i]] = i
	nextMaxIn = 0
	isAnswerNo = False
	for i in range(1, n + 1):
		if nextMaxIn != 0:
			if position[i] != nextMaxIn:
				isAnswerNo = True
				break
			else:
				nextMaxIn += 1
		else:
			nextMaxIn = position[i] + 1
		if nextMaxIn == n + 1 or isVisited[nextMaxIn] == 1:
			nextMaxIn = 0
		isVisited[position[i]] = 1
	if isAnswerNo == False:
		print('YES')
	else:
		print('NO')


def gen(n, p):
	while n:
		k = p[n - 1]
		for i in range(1, k + 1):
			if p[n - i] != k + 1 - i:
				return 'NO'
		for i in range(n - k):
			p[i] -= k
		n -= k
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	print(gen(n, p))


t = int(input())

def solve(n, p):
	for i in range(0, n - 1):
		if p[i] + 1 < p[i + 1]:
			return False
	return True
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	if solve(n, p):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	s = [p[0]]
	for i in range(1, n):
		if p[i - 1] + 1 != p[i]:
			s.append(p[i])
	for i in range(1, len(s)):
		if s[i] > s[i - 1]:
			print('No')
			break
	else:
		print('Yes')


def mult_input():
	return map(int, input().split())

def list_input():
	return list(map(int, input().split()))
for nt in range(int(input())):
	n = int(input())
	l = list_input()
	ans = 'Yes'
	k = 1
	locations = {}
	for i in range(n):
		locations[l[i]] = i
	covered = n
	while k < n + 1:
		ind = locations[k]
		for i in range(ind, covered):
			if l[i] != k:
				ans = 'No'
				break
			k += 1
		if ans == 'No':
			break
		else:
			covered = ind
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = True
	b = [0] * (n + 1)
	for i in range(n):
		b[a[i]] = i + 1
	p = 1
	r = n
	while p <= n:
		l = b[p]
		i = l
		while i <= r:
			if b[p] != i:
				f = False
				break
			else:
				p += 1
				i += 1
		if not f:
			break
		r = l - 1
	if f:
		print('YES')
	else:
		print('NO')


tc = int(input().strip())

def solve():
	n = int(input().strip())
	curr_orien = list(map(int, input().strip().split()))
	curr_pos = {curr_orien[i]: i for i in range(len(curr_orien))}
	all_pos = [False for i in range(len(curr_orien))]
	k = 1
	lst_pos = len(curr_orien)
	while k <= n:
		p = curr_pos[k]
		if curr_orien[p:lst_pos] != list(range(k, k + lst_pos - p)):
			print('No')
			return
		k += lst_pos - p
		lst_pos = p
	print('Yes')
for t in range(1, tc + 1):
	solve()


from operator import itemgetter
t = int(input())
for i in range(t):
	n = int(input())
	pi = list(map(int, input().split()))
	ans = ['Yes', 'No']
	if n < 3:
		print(ans[0])
		continue
	pi2 = [[pi[i], i] for i in range(n)]
	pi2.sort(key=itemgetter(0))
	i = 0
	num = 0
	while i < n:
		j = pi2[i][1] + 1
		while j < n:
			if pi[j] > pi[j - 1] + 1:
				ans[0] = ans[1]
				i = n
			if pi[j] < pi[j - 1]:
				break
			j += 1
		i = pi[j - 1]
	print(ans[0])


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	flag = 0
	l = []
	if n == 1:
		print('YES')
		flag = 1
	o = p.index(1)
	while flag == 0 and o < n - 1:
		if p[o + 1] != p[o] + 1:
			flag = 1
			print('NO')
			break
		o += 1
	if flag == 0:
		i = 0
		while i < n - 1:
			while i < n - 1 and p[i + 1] > p[i]:
				if p[i + 1] != p[i] + 1:
					flag = 1
					break
				i += 1
			i += 1
		if flag == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print('Yes')
	else:
		if l[0] == n:
			y = 1
			x = l[1]
		else:
			y = 0
			x = l[0]
		f = 0
		for i in range(y + 1, n):
			if l[i] > l[i - 1] and l[i] > x and (l[i] == l[i - 1] + 1):
				continue
			elif l[i] > l[i - 1] and l[i] > x and (l[i] != l[i - 1] + 1):
				f = 1
				break
			elif l[i] < x:
				x = l[i]
		if f:
			print('No')
		else:
			print('Yes')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split(' ')]
	f = True
	g = li.pop()
	d = set()
	while len(li):
		if g == li[-1] + 1:
			d.add(g)
			g = li.pop()
		elif g == 1:
			d.add(g)
			g = li.pop()
		elif g - 1 in d:
			d.add(g)
			g = li.pop()
		else:
			f = False
			break
	if f:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = True
	for i in range(n - 1):
		if a[i + 1] > a[i] and a[i + 1] - a[i] != 1:
			res = False
	if res:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	chk = True
	for i in range(1, n):
		if a[i] == a[i - 1] + 1:
			continue
		elif a[i - 1] + 1 < a[i]:
			chk = False
			break
		else:
			continue
	if chk:
		print('YES')
	else:
		print('NO')


N = int(input())
for i in range(N):
	n = int(input())
	p = list(map(int, input().rstrip().split()))
	arg = [0] * n
	for i in range(n):
		arg[p[i] - 1] = i
	occ = [1] * n
	maxi = 1
	err = False
	for i in range(n):
		pos = arg[i]
		if occ[pos] != maxi:
			err = True
			break
		else:
			v = occ[pos]
			occ[pos] = -1
			found = False
			for j in range(pos + 1, n):
				if occ[j] != -1:
					maxi = maxi + occ[j]
					occ[j] += v
					found = True
					break
			if not found:
				maxi = 1
	if err:
		print('No')
	else:
		print('Yes')


t = int(input())
for tt in range(t):
	n = int(input())
	p = list(map(int, input().split(' ')))
	p_broken = []
	for i in range(n):
		p_broken.append(list())
	prev = 0
	j = 0
	for i in range(n):
		if prev > p[i]:
			j += 1
		p_broken[j].append(p[i])
		prev = p[i]
	N = j + 1
	minmax = []
	for i in range(n):
		minmax.append(list())
	for i in range(N):
		minmax[i].append(p_broken[i][0])
		minmax[i].append(p_broken[i][-1])
	bhul = True
	for i in range(N - 1):
		if minmax[i][0] != 1 + minmax[i + 1][1]:
			bhul = False
			print('No')
			break
	if bhul:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ind = [0] * n
	for i in range(n):
		ind[a[i] - 1] = i
	c = [1] * n
	flag = 1
	for i in range(n):
		t = c[ind[i]]
		c[ind[i]] = -1
		if ind[i] < n - 1 and c[ind[i] + 1] != -1:
			c[ind[i] + 1] += t
			if ind[i + 1] != ind[i] + 1:
				flag = 0
				break
	if flag == 0:
		print('No')
	else:
		print('Yes')


import sys
input = sys.stdin.readline
t = int(input())
out = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	smol = l[0]
	works = True
	for i in range(1, n):
		if l[i] == l[i - 1] + 1:
			pass
		elif l[i] > smol:
			works = False
			break
		smol = min(smol, l[i])
	if works:
		out.append('Yes')
	else:
		out.append('No')
print('\n'.join(out))


import sys
import math
from collections import defaultdict

def solve(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	count = 1
	rec = {}
	for i in range(n):
		rec[p[i]] = i
	end = n
	while count <= n:
		start = rec[count]
		for i in range(start, end):
			if p[i] == count:
				count += 1
			else:
				print('No')
				return
		end = start
	print('Yes')
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	raj = dict()
	for i in range(n):
		raj[arr[i]] = i
	rishi = dict()
	for i in range(n):
		rishi[i] = arr[i]
	ans = 'Yes'
	low = float('inf')
	for i in range(1, n):
		if i == 1:
			x = raj.get(i)
			low = min(low, x)
		else:
			x = raj.get(i)
			if raj.get(i - 1) + 1 == x:
				continue
			elif raj.get(i - 1) == n - 1 or rishi.get(raj.get(i - 1) + 1) < i:
				continue
			else:
				ans = 'No'
				break
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [a[0]]
	for i in range(1, n):
		if a[i] == a[i - 1] + 1:
			continue
		c.append(a[i])
	b = sorted(c, reverse=True)
	if b == c:
		print('Yes')
	else:
		print('No')


T = int(input())
while T:
	n = int(input())
	P = list(map(int, input().split()))
	D = {}
	for i in range(n):
		D[P[i]] = i + 1
	F = 'Yes'
	for i in range(2, n + 1):
		if D[i] > D[i - 1] + 1:
			F = 'No'
	print(F)
	T = T - 1


def f():
	n = int(input())
	A = [int(s) for s in input().split()]
	i = n - 1
	start = 1
	end = A[-1]
	cur = end
	while i >= 0:
		if A[i] != cur:
			print('No')
			return
		if cur == start:
			start = end + 1
			end = A[i - 1]
			cur = end
		else:
			cur -= 1
		i -= 1
	print('Yes')
for t in range(int(input())):
	f()


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	res = True
	for j in range(1, n):
		if nums[j] == nums[j - 1] + 1 or nums[j] < nums[j - 1]:
			continue
		else:
			res = False
			break
	if res:
		ans.append('Yes')
	else:
		ans.append('No')
for i in ans:
	print(i)


ans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	ind = [0]
	for i in range(1, n):
		if u[i] < u[i - 1]:
			ind.append(i)
	ind.append(n)
	w = []
	for i in range(len(ind) - 2, -1, -1):
		for j in range(ind[i], ind[i + 1]):
			w.append(u[j])
	for i in range(1, n - 1):
		if not w[i - 1] < w[i] < w[i + 1]:
			ans.append('NO')
			break
	else:
		ans.append('YES')
print('\n'.join(ans))


from sys import stdin, stdout
t = int(input())
while t:
	t = t - 1
	n = int(stdin.readline())
	if n == 1:
		_ = stdin.readline()
		stdout.write('YES\n')
	else:
		p = [int(s) for s in stdin.readline().split()]
		id = [0 for i in range(n)]
		for i in range(n):
			id[p[i] - 1] = i
		for i in range(n):
			id[i] = id[i] - i
		ans = 1
		for i in range(1, n):
			if id[i] > id[i - 1]:
				ans = 0
		if ans:
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')


import sys
input = sys.stdin.readline

def solve(L):
	posL = [None] * len(L)
	for i in range(len(L)):
		posL[L[i] - 1] = i + 1
	visited = [False] * len(L)
	for i in range(len(posL)):
		if i == 0:
			visited[posL[i] - 1] = True
			continue
		if posL[i - 1] + 1 == posL[i]:
			visited[posL[i] - 1] = True
			continue
		if posL[i - 1] == len(posL) or visited[posL[i - 1]]:
			visited[posL[i] - 1] = True
			continue
		return False
	return True
for i in ' ' * int(input()):
	n = int(input())
	L = list(map(int, input().split()))
	if solve(L):
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.buffer.readline
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	idx = [0] * n
	for (i, x) in enumerate(a):
		idx[x - 1] = i
	done = [0] * n
	f = 1
	for (x, i) in enumerate(idx):
		if i == n - 1 or done[i] or done[i + 1]:
			done[i] = 1
			continue
		if a[i + 1] != x + 2:
			f = 0
			break
		done[i] = 1
	if f:
		ans.append('Yes')
	else:
		ans.append('No')
print('\n'.join(ans))


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
IN = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def s(a):
	print(' '.join(list(map(str, a))))
t = I()
for i in range(t):
	n = I()
	a = L()
	f = 'YES'
	for i in range(1, len(a)):
		if a[i] > a[i - 1] + 1:
			f = 'NO'
			break
	print(f)


import re
t = int(input())
if t == 100000:
	print('Yes\n' * 100000)
else:
	for _ in range(t):
		n = int(input())
		if n < 3:
			input()
			print('Yes')
			continue
		prev = None
		out = 'Yes'
		for num in re.finditer('[0-9]+', input()):
			x = int(num.group())
			if prev and x > prev + 1:
				out = 'No'
				break
			prev = x
		print(out)


for _ in range(int(input())):
	n = int(input())
	arr = [int(s) for s in input().split()]
	pos = [-1] * (n + 1)
	for i in range(len(arr)):
		pos[arr[i]] = i
	flag = True
	for i in range(2, n + 1):
		if pos[i] == pos[i - 1] + 1 or pos[i] < pos[i - 1]:
			continue
		else:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	ind = {a[i]: i + 1 for i in range(n)}
	occupied = defaultdict(bool)
	occupied[ind[1]] = True
	last = n
	ok = 'YES'
	if ind[1] == n:
		last = n - 1
	for i in range(2, n + 1):
		if ind[i] < ind[i - 1] and last > ind[i - 1]:
			ok = 'NO'
			break
		if ind[i] != ind[i - 1] + 1 and last > ind[i - 1]:
			ok = 'NO'
			break
		occupied[ind[i]] = True
		while occupied[last]:
			last -= 1
	print(ok)


r = input

def f():
	(a, n) = (0, int(r()))
	for q in r().split():
		b = int(q)
		if not a:
			k = b - 1
		elif b != a + 1:
			if a != n:
				return 'No'
			n = k
			k = b - 1
		a = b
	return 'Yes'
for t in range(int(r())):
	print(f())


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	ok = True
	max_val = 0
	cnt = 0
	prev = 0
	for item in a[::-1]:
		if item == prev - 1:
			cnt += 1
		else:
			if cnt != max_val:
				ok = False
			cnt += 1
		if max_val < item:
			max_val = item
		prev = item
	if ok:
		print('Yes')
	else:
		print('No')


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	index = [-1] * n
	for i in range(len(a)):
		index[a[i] - 1] = i
	an = 'YES'
	end = n - 1
	nxt = index[0] - 1
	for i in range(1, len(index)):
		if index[i - 1] == end:
			if index[i] > nxt:
				an = 'NO'
				break
			end = nxt
			nxt = index[i] - 1
		elif index[i - 1] + 1 != index[i]:
			an = 'NO'
			break
	print(an)


import sys, math
t = int(sys.stdin.readline())
for T in range(t):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	temp = [0] * n
	for i in range(1, n):
		if arr[i] == arr[i - 1] + 1 or arr[i] < arr[i - 1]:
			temp[i] = 1
	if temp.count(1) == n - 1:
		print('Yes')
	else:
		print('No')


for q in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	now = p[0] - 1
	last_now = 0
	first = True
	i = 1
	while i < n and (p[i] - 1 == p[i - 1] or first):
		if p[i] - 1 != p[i - 1]:
			first = False
			last_now = now
			now = p[i] - 1
		if p[i] == last_now:
			first = True
		i += 1
	if i < n or not first:
		print('NO')
	else:
		print('YES')


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	hashi = dict()
	for i in range(n):
		hashi[li[i]] = i
	arr = [0 for i in range(n)]
	poss = 1
	for i in range(1, n):
		if i == 1:
			arr[hashi[i]] = 1
		else:
			k = hashi[i - 1]
			if k + 1 == n or arr[k + 1] == 1:
				arr[hashi[i]] = 1
			elif hashi[i] != k + 1:
				poss = 0
				break
			else:
				arr[hashi[i]] = 1
	if poss == 0:
		print('No')
	else:
		print('Yes')


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	arr = map(int, stdin.readline().split())
	max_ = next(arr)
	last = max_
	for i in arr:
		if last + 1 == i:
			last = i
			continue
		if max_ < i:
			print('No')
			break
		max_ = i
		last = i
	else:
		print('Yes')


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	res = 'Yes'
	for i in range(n - 1):
		if a[i + 1] > a[i] + 1:
			res = 'No'
			break
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	bol = True
	for j in range(1, n):
		if a[j] == a[j - 1] + 1 or a[j] < a[j - 1]:
			continue
		else:
			bol = False
			break
	if bol:
		print('Yes')
	else:
		print('No')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	P = list(map(int, input().split()))
	PINV = [-1] * (n + 1)
	for (ind, num) in enumerate(P):
		PINV[num] = ind
	last = n - 1
	now = n - 1
	start = -1
	for i in range(1, n + 1):
		if start == -1:
			now = PINV[i]
			start = PINV[i]
		elif PINV[i] == now + 1:
			now += 1
		else:
			print('No')
			break
		if now == last:
			now = start - 1
			last = start - 1
			start = -1
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	perm = list(map(int, input().split()))
	last = perm[0]
	for p in perm[1:]:
		if not p - last <= 1:
			print('No')
			break
		last = p
	else:
		print('Yes')


leng = int(input())
for i in range(leng * 2):
	z = input().split()
	z = [int(x) for x in z]
	ok = 1
	if i % 2 == 1:
		for j in range(len(z) - 1):
			if z[j + 1] == z[j] + 1 or z[j + 1] < z[j]:
				pass
			else:
				ok = 0
		if sum(z) != len(z) * (len(z) + 1) / 2:
			ok = 0
		if ok == 1:
			print('Yes')
		else:
			print('No')


import sys

def input():
	return sys.stdin.readline()[:-1]
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	rm = n
	not_rm = False
	ok = True
	for x in p:
		if not not_rm:
			if x == rm:
				rm -= 1
			else:
				not_rm = True
				last = x
				lm = x
		elif x != last + 1:
			ok = False
			break
		elif x == rm:
			not_rm = False
			rm = lm - 1
		else:
			last = x
	if ok:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[arr[i]] = i + 1
	ans = [0 for i in range(n)]
	ind = 1
	while ind < n + 1:
		prev = ind
		pos = d[ind]
		for i in range(pos - 1, n):
			if ans[i] != 0:
				break
			else:
				ans[i] = ind
				ind += 1
		if prev == ind:
			break
	if ans == arr:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	location = [0 for i in range(n + 1)]
	for i in range(len(arr)):
		location[arr[i]] = i
	k = 1
	flag = 1
	while k < n:
		if location[k] == n - k:
			k += 1
			continue
		else:
			currloc = location[k]
			for i in range(currloc, n - k):
				if arr[i + 1] != arr[i] + 1:
					k = n + 1
					flag = 0
					break
				else:
					k = arr[i + 1]
			k += 1
	if flag:
		print('Yes')
	else:
		print('No')


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	n = int(input())
	a = [0] + list(mapi())
	f = 1
	b = [0] * (n + 1)
	c = [-1] * (n + 1)
	c[0] = 0
	for i in range(1, n + 1):
		b[a[i]] = i
	i = 1
	while i <= n:
		tmp = b[i]
		c[tmp] = i
		i += 1
		j = tmp + 1
		while j < n and c[j] == -1:
			c[j] = i
			i += 1
			j += 1
	if a == c:
		print('Yes')
	else:
		print('No')


from sys import stdin
from collections import Counter, deque
input = stdin.buffer.readline
T = int(input())
for _ in range(T):
	n = int(input())
	ls = list(map(int, input().split()))
	(cc, tl) = ([], [])
	for i in range(n):
		tl.append(ls[i])
		if i == n - 1 or ls[i] > ls[i + 1]:
			cc.append(tl)
			tl = []
	cc.reverse()
	cc = [u for sl in cc for u in sl]
	print('Yes' if cc == list(range(1, n + 1)) else 'No')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	pos = {}
	for i in range(n):
		pos[p[i]] = i
	r = n - 1
	ans = True
	f = 1
	while ans and f <= n:
		if pos[f] > r:
			ans = False
			break
		newR = pos[f] - 1
		while pos[f] < r:
			f += 1
			if pos[f] != pos[f - 1] + 1:
				ans = False
				break
		r = newR
		f += 1
	if ans == True:
		print('Yes')
	else:
		print('No')


import sys
from math import log2, floor, ceil, sqrt
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	n = int(ri())
	a = Ri()
	dic = {}
	for i in range(n):
		dic[a[i]] = i + 1
	r = [i for i in range(n + 1)]
	c = [0 for i in range(n + 1)]
	arr = [-1] * (n + 2)
	arr[n + 1] = 3
	ite = -1
	flag = True
	for i in range(1, n + 1):
		pos = dic[i]
		if ite == -1:
			if arr[pos] == -1:
				arr[pos] = i
				ite = pos + 1
				if arr[ite] != -1:
					ite = -1
			else:
				flag = False
				break
		elif pos != ite:
			flag = False
			break
		elif arr[pos] == -1:
			arr[pos] = i
			ite = pos + 1
			if arr[ite] != -1:
				ite = -1
		else:
			flag = False
			break
	if flag:
		Yes()
	else:
		No()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.reverse()
	i = 0
	sol = 'Yes'
	while i < len(l):
		size = l[i] - i
		end = False
		for j in range(size):
			if l[i + j] != i + size - j:
				end = True
				break
		if end:
			sol = 'No'
			break
		i += size
	print(sol)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	now = 1
	yes = 0
	j = -1
	counter = 0
	while yes == 0 and counter != n:
		elem = a[j]
		for i in range(a[j], now - 1, -1):
			if a[j] != i:
				print('No')
				yes = 1
				break
			j -= 1
			counter += 1
		if a[j + 1] == i:
			now = elem + 1
	if yes == 0:
		print('Yes')


from sys import stdin
for _ in range(int(input())):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	ans = 'Yes'
	for i in range(n - 1):
		if l[i + 1] > l[i] + 1:
			ans = 'No'
			break
	print(ans)


def C():
	t = int(input())
	while t != 0:
		t = t - 1
		n = int(input())
		Arr = list(map(int, input().split()))
		flag = False
		for i in range(1, len(Arr)):
			if Arr[i - 1] < Arr[i]:
				if Arr[i] - Arr[i - 1] > 1:
					flag = True
					print('No')
					break
		if flag == False:
			print('Yes')
C()


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	l = []
	r = [0] * (n + 1)
	d = {}
	c = 0
	for i in range(n):
		d[a[i]] = i + 1
	r[d[1]] = 1
	for i in range(2, n + 1):
		if d[i - 1] + 1 <= n and r[d[i - 1] + 1] == 0:
			if d[i] != d[i - 1] + 1:
				c = 1
				break
		r[d[i]] = 1
	if c == 1:
		print('No')
	else:
		print('Yes')


R = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	pmin = prev = 10 ** 6
	good = True
	for num in R():
		if num != prev + 1:
			good = good and num < pmin
			pmin = num
		prev = num
	print('YES' if good else 'NO')


def get_ans(n, transp):
	(k, k_next) = (1, transp[-1] + 1)
	i = n - 1
	while i > 0:
		while transp[i] != k:
			if transp[i] != transp[i - 1] + 1:
				return False
			i -= 1
		i -= 1
		(k, k_next) = (k_next, transp[i] + 1)
	return True
for test_i in range(int(input())):
	n = int(input())
	transp = list(map(int, input().split()))
	print('Yes' if get_ans(n, transp) else 'No')


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		input()
		print('Yes')
		continue
	p = [0] * n
	end = n
	arr = list(map(int, input().rstrip().split(' ')))
	cur = 1
	flag = True
	for ele in arr:
		p[ele - 1] = cur
		cur += 1
	chooseAny = True
	nextChoice = None
	reduceLen = 0
	for ele in p:
		if not chooseAny and ele != nextChoice:
			print('No')
			flag = False
			break
		if ele == end:
			end -= reduceLen + 1
			chooseAny = True
			reduceLen = 0
		else:
			chooseAny = False
			nextChoice = ele + 1
			reduceLen += 1
	if flag == True:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	my_map = [0] * (n + 1)
	for i in range(n):
		my_map[data[i]] = i + 1
	blocked = set()
	blocked.add(n + 1)
	now = 1
	result = True
	while now < n:
		index = my_map[now]
		blocked.add(index)
		if index + 1 not in blocked:
			if my_map[now + 1] != index + 1:
				result = False
				break
		now += 1
	if result:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	flag = False
	for i in range(1, n):
		if l[i] != l[i - 1] + 1 and l[i] > l[i - 1]:
			flag = True
			break
	if not flag:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	P = list(map(int, input().split()))
	w = {}
	for (i, p) in enumerate(P):
		w[p] = i
	lp = n
	cur = 1
	inv = False
	while cur <= n:
		st = w[cur]
		end = lp
		for i in range(end - st):
			if P[st + i] != cur + i:
				inv = True
				break
		if inv:
			break
		lp = w[cur]
		cur += end - st
	if inv:
		print('No')
	else:
		print('Yes')


def inp():
	x = int(input())
	return x

def linp():
	x = [int(i) for i in input().split()]
	return x
T = inp()
ans = []
for t in range(T):
	n = inp()
	a = linp()
	answer = True
	i = 0
	cnt = 0
	s1 = a[0]
	s2 = 0
	while i + 1 < n and answer:
		if a[i + 1] - a[i] > 1:
			answer = False
		elif a[i + 1] < a[i]:
			cnt += 1
			if cnt == 1:
				s2 = a[i + 1]
			elif a[i] + 1 == s1:
				s1 = s2
				s2 = a[i + 1]
			else:
				answer = False
		i += 1
	ans.append('Yes' if answer else 'No')
for a in ans:
	print(a)


from sys import stdin
t = int(input())
for _ in range(t):
	n = int(stdin.readline())
	p = list(map(int, stdin.readline().split()))
	for i in range(n - 1):
		if p[i] + 1 < p[i + 1]:
			print('NO')
			break
	else:
		print('YES')


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		n = int(input())
		pp = [int(a) for a in input().split()]
		for i in range(n - 1):
			if pp[i + 1] > pp[i] and pp[i + 1] != pp[i] + 1:
				print('No')
				return
		print('Yes')
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	prev = p[0]
	prev_start = p[0]
	flag = True
	for e in p[1:]:
		if e != prev + 1:
			if prev_start < e:
				flag = False
			else:
				prev_start = e
		prev = e
	if flag:
		print('Yes')
	else:
		print('No')


from collections import deque
n_cases = int(input())
for case_num in range(n_cases):
	n = int(input())
	p = [int(x) for x in input().split()]
	pairs = sorted([(x, i) for (i, x) in enumerate(p)])
	left = -1
	size = 0
	right = n
	ok = True
	for (x, i) in pairs:
		if left == -1:
			size = 1
			left = i
		elif i == left + size:
			size += 1
		elif left + size == right:
			right = left
			left = i
			size = 1
		else:
			ok = False
	if ok:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	if n == 1 and p[0] == 1:
		print('YES')
		continue
	flag = 1
	last_count = n
	i = 0
	ref = p[i]
	ref_ind = i
	while i < n:
		if i == n:
			break
		if i < n:
			while i < n and p[i] != last_count and (p[i] - ref == i - ref_ind):
				if i == n:
					break
				i += 1
			if i == n:
				break
			if i < n and p[i] == last_count and (p[i] - ref == i - ref_ind):
				if i == n:
					break
				last_count = ref - 1
				ref_ind = i + 1
				i += 1
				if i < n and p[i] < ref:
					ref = p[i]
				continue
			else:
				flag = 0
				break
	print(['NO', 'YES'][flag])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if l[0] == 1:
		r = sorted(l)
		if l == r:
			print('Yes')
		else:
			print('No')
	else:
		l1 = [l[0]]
		for i in range(n - 1):
			if l[i] - l[i + 1] != -1:
				l1.append(l[i + 1])
		r = sorted(l1)
		r = r[::-1]
		if r == l1:
			print('Yes')
		else:
			print('No')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	for i in range(1, n):
		if a[i] - a[i - 1] > 1:
			print('No')
			break
	else:
		print('Yes')


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ans = 'Yes'
	check = [1 for _ in range(n)]
	indd = [0 for _ in range(n + 1)]
	for j in range(n):
		indd[s[j]] = j
	maxx = 1
	for j in range(1, n + 1):
		if check[indd[j]] != maxx:
			ans = 'No'
			break
		else:
			now = indd[j]
			if indd[j] + 1 < n:
				if check[indd[j] + 1] != 0:
					check[indd[j] + 1] += check[indd[j]]
				indd[j] = indd[j] + 1
				if maxx < check[indd[j]]:
					maxx = check[indd[j]]
			check[now] = 0
			if check[indd[j]] == check[now]:
				maxx = 1
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	d = [0 for i in range(n + 2)]
	flag = 0
	for i in range(n):
		d[a[i]] = i
	f = [0 for i in range(n + 2)]
	for i in range(1, n):
		if d[i + 1] != d[i] + 1 and (f[d[i] + 1] == 0 and (not d[i] == n - 1)):
			flag = 1
			break
		f[d[i]] = 1
	print('Yes' if flag == 0 else 'No')


import sys
from operator import add
input = sys.stdin.buffer.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def ref(N, P):
	P = [p - 1 for p in P]
	ii = {}
	for (i, p) in enumerate(P):
		ii[p] = i
	ans = [-1] * N
	for i in range(N):
		R = []
		for j in range(N):
			for k in range(j, N):
				if ans[k] == -1:
					R.append(k)
					break
			else:
				R.append(-1)
		C = [0] * N
		for r in R:
			if r != -1:
				C[r] += 1
		if C[ii[i]] != max(C):
			return 'No'
		ans[ii[i]] = i
	return 'Yes'

def slv(N, P):
	ii = {}
	for (i, p) in enumerate(P):
		ii[p - 1] = i
	done = set()
	done.add(N)
	pre = None
	for i in range(N):
		if pre is None:
			pre = ii[i]
		else:
			if pre + 1 != ii[i]:
				return 'No'
			pre = ii[i]
		done.add(pre)
		if pre + 1 in done:
			pre = None
	return 'Yes'

def main():
	T = read_int()
	for _ in range(T):
		N = read_int()
		P = read_int_n()
		print(slv(N, P))
main()


from sys import *
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	end = n - 1
	d = {}
	ele = 1
	ver = True
	for i in range(n):
		d[a[i]] = i
	while ele <= n:
		pos = d[ele]
		prev = ele
		while pos != end:
			if a[pos] + 1 != a[pos + 1]:
				ver = False
				break
			pos += 1
			ele += 1
		ele += 1
		end = d[prev] - 1
		if ver == False:
			break
	if ver:
		stdout.write(str('Yes') + '\n')
	else:
		stdout.write(str('No') + '\n')


for i in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	ind = [0] * (n + 1)
	for i in range(n):
		ind[p[i]] = i
	f = 0
	c = 1
	till = n
	k = 0
	while k < n:
		j = ind[c]
		for i in range(j, till):
			k += 1
			if p[i] == c:
				c += 1
			else:
				f = 1
				break
		if f == 1:
			break
		till = j
	if f == 0:
		print('Yes')
	else:
		print('No')


import math
import operator as op
from functools import reduce
from fractions import Fraction as frac

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom

def gna(A, p):
	i = 0
	while p + i < len(A) and A[p] == A[p] + i:
		i += 1
	i -= 1
	return i
t = int(input())
for term in range(1, t + 1):
	n = int(input())
	A = list(map(int, input().split()))
	idx = {}
	for i in range(n):
		idx[A[i]] = i
	if len(A) <= 2:
		print('Yes')
	else:
		ans = 'Yes'
		if n <= 2:
			ans = 'Yes'
		else:
			for i in range(1, n):
				if A[i] != 1:
					if not (A[i] - 1 == A[i - 1] or idx[A[i] - 1] > i):
						ans = 'No'
						break
		print(ans)


from sys import stdin, stdout
import math, collections
mod = 10 ** 9 + 7
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	visited = [False] * n
	ans = True
	visited[arr[0] - 1] = True
	for i in range(n - 1):
		if arr[i] + 1 <= n and arr[i + 1] != arr[i] + 1 and (not visited[arr[i]]):
			ans = False
			break
		visited[arr[i + 1] - 1] = True
	print('YES' if ans else 'NO')


def solve():
	n = int(input())
	li = [int(x) for x in input().split()]
	d = {}
	for i in range(n):
		d[li[i]] = i
	(i, last_val) = (1, 1)
	pos = d[i]
	last = n - 1
	while i < n:
		if pos == last:
			pos = d[i + 1]
			last = d[last_val] - 1
			last_val = i + 1
		elif li[pos] != i or li[pos + 1] != i + 1:
			print('NO')
			break
		else:
			pos += 1
		i += 1
	else:
		print('YES')
t = int(input())
for i in range(t):
	solve()