#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long n, k, t, m, q, flag = 0;
long long po(long long k, long long n, long long ans, long long temp,
             long long ans1) {
  if (n == 0) return ans;
  while (temp <= n) {
    ans *= ans1;
    ans %= mod;
    ans1 = ans1 * ans1;
    ans1 %= mod;
    n = n - temp;
    temp *= 2;
  }
  return po(k, n, ans, 1, k) % mod;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n <= 2) {
      cout << "YES"
           << "\n";
      continue;
    }
    long long temp;
    for (int i = 0; i < n; i++)
      if (a[i] == 1) temp = i;
    long long flag = 0;
    long long i = temp;
    if (a[(i + 1 + n) % n] - a[i] == 1) {
      long long f = 0;
      for (int j = 0; j < n - 1; j++) {
        if (a[(j + temp + 1 + n) % n] - a[(j + temp + n) % n] == 1)
          ;
        else {
          f = 1;
          break;
        }
      }
      if (f == 0)
        cout << "YES"
             << "\n";
      else
        cout << "NO"
             << "\n";
      continue;
    } else if (a[(i - 1 + n) % n] - a[i] == 1) {
      long long f = 0;
      for (int j = 0; j < n - 1; j++) {
        if (a[(-j + temp - 1 + n + n) % n] - a[(-j + temp + n + n) % n] == 1)
          ;
        else {
          f = 1;
          break;
        }
      }
      if (f == 0)
        cout << "YES"
             << "\n";
      else
        cout << "NO"
             << "\n";
      continue;
    } else
      cout << "NO"
           << "\n";
  }
  return 0;
}
