#include <bits/stdc++.h>
using namespace std;
int q, n, p[205];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    bool ok1 = true;
    bool ok2 = true;
    for (int i = 1; i <= n; ++i) cin >> p[i];
    for (int i = 2; i <= n; ++i) {
      if (ok1) {
        int x = p[i - 1] + 1;
        if (x > n) x = 1;
        if (x != p[i]) ok1 = false;
      }
      if (ok2) {
        int x = p[i - 1] - 1;
        if (x < 1) x = n;
        if (x != p[i]) ok2 = false;
      }
    }
    if (ok1 || ok2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
