#include <bits/stdc++.h>
using namespace std;
int n, p, c, b;
int main() {
  int cases;
  cin >> cases;
  int index;
  while (cases--) {
    cin >> n;
    int arr[200];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] == 1) {
        index = i;
      }
    }
    b = 0;
    p = index;
    while (b < n) {
      if (arr[(index) % n] != b + 1) {
        break;
      }
      b++;
      index++;
    }
    c = 0;
    index = p;
    while (c < n) {
      if (arr[(n + index % n) % n] != c + 1) {
        break;
      }
      c++;
      index--;
    }
    if (c != n && b != n) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
