#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int mini = 0;
    int minv = a[0];
    for (int i = 0; i < n; i++) {
      if (a[i] < minv) {
        minv = a[i];
        mini = i;
      }
    }
    bool flag;
    if (a[(mini + n - 1) % n] - a[mini] == 1)
      flag = 0;
    else
      flag = 1;
    int count = 0;
    for (int i = 0; i < n - 1; i++) {
      if (flag) {
        if (a[(mini + 1 + i) % n] - a[(mini + i) % n] == 1) count++;
      } else {
        if (a[(mini - i - 1 + n) % n] - a[(mini - i + n) % n] == 1) count++;
      }
    }
    if (count == (n - 1))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
