#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t > 0) {
    t--;
    int n;
    cin >> n;
    vector<int> ar(n);
    for (int i = 0; i < n; i++) {
      cin >> ar[i];
    }
    int one, f = 1;
    for (int i = 0; i < n; i++) {
      if (ar[i] == 1) {
        one = i;
        break;
      }
    }
    if (ar[(one + 1) % n] == 2) {
      for (int i = one; i < one + n - 1; i++) {
        if (ar[i % n] != ar[(i + 1) % n] - 1) {
          f = 0;
          break;
        }
      }
    } else if (ar[(one + 1) % n] == n) {
      for (int i = one + 1; i < one + n; i++) {
        if (ar[i % n] != ar[(i + 1) % n] + 1) {
          f = 0;
          break;
        }
      }
    } else {
      f = 0;
    }
    if (f == 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
