import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; immutable long MOD = 998244353; void solve() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; auto cnt = new int[](N); A[] -= 1; foreach (a; A) cnt[a] += 1; if (cnt.any!(a => a !=2)) { writeln("No"); return; } if (A.front != 0) { writeln("No"); return; } if (A.back != N-1) { writeln("No"); return; } writeln("Yes"); } void main() { auto T = readln.chomp.to!int; while (T--) { solve; } }