#include <bits/stdc++.h>
using namespace std;
int a[205];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    memset(a, 0, sizeof(a));
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    int flg = 0;
    if (a[0] == 1 && a[n - 1] == n) {
      flg = 1;
      for (int i = 1; i < n - 1; i++) {
        if (a[i] != i + 1) {
          flg = 0;
          break;
        }
      }
    } else if (a[0] == n && a[n - 1] == 1) {
      flg = 1;
      for (int i = 1; i < n - 1; i++) {
        if (a[i] != a[i - 1] - 1) {
          flg = 0;
          break;
        }
      }
    } else if (a[0] - a[n - 1] == 1) {
      flg = 1;
      for (int i = 1; i <= n - a[0]; i++) {
        if (a[i] != a[i - 1] + 1) {
          flg = 0;
          break;
        }
      }
      int tmp1 = 1;
      for (int i = n - a[0] + 1; i < n - 1; i++) {
        if (a[i] != tmp1++) {
          flg = 0;
          break;
        }
      }
    } else if (a[n - 1] - a[0] == 1) {
      flg = 1;
      for (int i = 1; i <= a[0] - 1; i++) {
        if (a[i] != a[i - 1] - 1) {
          flg = 0;
          break;
        }
      }
      int tmp2 = n;
      for (int i = a[0]; i < n - 1; i++) {
        if (a[i] != tmp2--) {
          flg = 0;
          break;
        }
      }
    }
    if (flg == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
