#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  for (long long u = 1; u <= t; u++) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long cnt = 0;
    for (long long i = 0; i < n - 1; i++) {
      if (a[i] == 1 || a[i] == n) {
        if (abs(a[i] - a[i + 1]) == 1 || abs(a[i] - a[i + 1]) == n - 1) cnt++;
      } else {
        if (abs(a[i] - a[i + 1]) == 1) cnt++;
      }
    }
    if (cnt == n - 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
