#include <bits/stdc++.h>
using namespace std;
const int num = 200001;
long long a[401];
int main() {
  int t, n;
  cin >> t;
  int str, cur;
  int fl = 0;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) a[n + i] = a[i];
    cur = 2 * n;
    int first = 1;
    for (int i = 0; i < cur; i++) {
      if (a[i] == first) {
        first++;
      } else {
        first = 1;
      }
      if (first == n) {
        fl = 1;
        break;
      }
    }
    first = n;
    for (int i = 0; i < cur; i++) {
      if (a[i] == first)
        first--;
      else
        first = n;
      if (first == 1) {
        fl = 1;
        break;
      }
    }
    if (fl)
      cout << "YES\n";
    else
      cout << "NO\n";
    fl = 0;
    for (int i = 0; i < cur; i++) a[i] = 0;
  }
  return 0;
}
