#include <bits/stdc++.h>
using namespace std;
void solve() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> p(n);
unordered_map<int, int> index_map;
for (int i = 0; i < n; i++) {
cin >> p[i];
index_map[p[i]] = i;
}
bool can_sort = true;
vector<int> sorted_p = p;
sort(sorted_p.begin(), sorted_p.end());
for (int i = 0; i < n - 1; i++) {
if (p[i] > p[i + 1] && abs(p[i] - p[i + 1]) != 1) {
can_sort = false;
break;
}
}
cout << (can_sort ? "YES" : "NO") << endl;
}
}
int main() {
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCkgewogICAgaW50IHQ7ICAKICAgIGNpbiA+PiB0OwogICAgCiAgICB3aGlsZSAodC0tKSB7CiAgICAgICAgaW50IG47CiAgICAgICAgY2luID4+IG47CiAgICAgICAgCiAgICAgICAgdmVjdG9yPGludD4gcChuKTsKICAgICAgICB1bm9yZGVyZWRfbWFwPGludCwgaW50PiBpbmRleF9tYXA7ICAKICAgICAgICAKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgICAgICBjaW4gPj4gcFtpXTsKICAgICAgICAgICAgaW5kZXhfbWFwW3BbaV1dID0gaTsgIAogICAgICAgIH0KCiAgICAgICAgYm9vbCBjYW5fc29ydCA9IHRydWU7CiAgICAgICAgCiAgICAgICAgdmVjdG9yPGludD4gc29ydGVkX3AgPSBwOwogICAgICAgIHNvcnQoc29ydGVkX3AuYmVnaW4oKSwgc29ydGVkX3AuZW5kKCkpOwoKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgaWYgKHBbaV0gPiBwW2kgKyAxXSAmJiBhYnMocFtpXSAtIHBbaSArIDFdKSAhPSAxKSB7CiAgICAgICAgICAgICAgICBjYW5fc29ydCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGNvdXQgPDwgKGNhbl9zb3J0ID8gIllFUyIgOiAiTk8iKSA8PCBlbmRsOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQo=