#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n, flag = 0, count = 0, index;
    cin >> n;
    int a[n + 2];
    for (int i = 1; i <= n; i++) {
      a[0] = 0;
      a[n + 1] = 0;
      cin >> a[i];
      if (a[i] == n) {
        index = i;
      }
    }
    if (n == 1 || n == 2) {
      cout << "YES"
           << "\n";
    } else {
      if (a[index + 1] == 1 || a[index - 1] == n - 1) {
        flag = a[1];
        for (int i = 1; i <= n; i++) {
          if (a[i] == n && (a[i - 1] == n - 1 || a[i + 1] == 1)) {
            flag = 1;
            count++;
          }
          if (a[i] == flag) {
            flag++;
            count++;
          }
        }
      }
      if (a[index - 1] == 1 || a[index + 1] == n - 1) {
        flag = a[1];
        for (int i = 1; i <= n; i++) {
          if (a[i] == 1 && (a[i - 1] == 2 || a[i + 1] == n)) {
            flag = n;
            count++;
          }
          if (a[i] == flag) {
            flag--;
            count++;
          }
        }
      }
      if (count == n) {
        cout << "YES"
             << "\n";
      } else
        cout << "NO"
             << "\n";
    }
  }
  return 0;
}
