#include using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; #define X first #define Y second #define SZ(a) ((int)a.size()) #define ALL(v) v.begin(), v.end() #define pb push_back void solve() { int n; cin >> n; vector arr(n), done(n); for (int &i : arr) cin >> i; queue q; for (int i = 0; i < n; ++i) if (arr[i] == 0) q.push(i); int cnt = 0; while (!q.empty()) { int u = q.front(); q.pop(), ++cnt; int prv = (u + n - 1) % n; int nxt = (u + 1) % n; if (!done[prv] && arr[prv] == 0) return cout << "No\n", void(); if (!done[nxt] && arr[nxt] == 0) return cout << "No\n", void(); if (!--arr[prv]) q.push(prv); if (!--arr[nxt]) q.push(nxt); done[u] = 1; } if (cnt < n) cout << "No\n"; else cout << "Yes\n"; } int main() { ios::sync_with_stdio(0), cin.tie(0); int t; cin >> t; while (t--) { solve(); } }