#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
const long long MOD = 1e9 + 7;
const long long oo = 1e18;
const long long N = 2e6 + 5;
long long a[N];
int main() {
  long long i, j, k;
  long long n, m, t;
  cin >> t;
  while (t--) {
    cin >> n;
    long long f = 0;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = n + 1; i <= n * 2; i++) a[i] = a[i - n];
    for (i = 1; i <= n; i++) {
      if (a[i] == 1) {
        if (a[i + 1] == n) {
          for (j = i + 2; j <= i + n - 1; j++)
            if (a[j] != a[j - 1] - 1) {
              f = 1;
              break;
            }
        } else if (a[i + 1] == 2) {
          for (j = i + 2; j <= i + n - 1; j++)
            if (a[j] != a[j - 1] + 1) {
              f = 1;
              break;
            }
        } else
          f = 1;
        break;
      }
    }
    if (f)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
