#include <bits/stdc++.h>
using namespace std;
int q;
int n;
int dancers[201];
int main() {
  ios::sync_with_stdio(false);
  cin >> q;
  while (q--) {
    cin >> n;
    int p, k;
    for (int i = 1; i <= n; ++i) {
      cin >> dancers[i];
      if (dancers[i] == 1) k = p = i;
    }
    if (n == 1) {
      cout << "YES" << endl;
      continue;
    }
    int flag1 = 1, flag2 = 1, last = dancers[k];
    for (;;) {
      p++;
      if (p > n) p = 1;
      if (dancers[p] - last != 1) {
        flag1 = 0;
        break;
      }
      last = dancers[p];
      if (dancers[p] == n) break;
    }
    last = dancers[k];
    p = k;
    for (;;) {
      p--;
      if (!p) p = n;
      if (dancers[p] - last != 1) {
        flag2 = 0;
        break;
      }
      last = dancers[p];
      if (dancers[p] == n) break;
    }
    if (flag1 || flag2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
