#include <bits/stdc++.h>
using namespace std;
long long int mini(long long int a, long long int b) {
  if (a >= b) return b;
  return a;
}
long long int maxi(long long int a, long long int b) {
  if (a >= b) return a;
  return b;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, f = 0, idx = -1, idx2;
    cin >> n;
    int a[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 1) idx = i;
    }
    for (int i = idx; i < idx + n; i++) {
      if (a[i % n] != i - idx + 1) {
        f += 1;
        break;
      }
    }
    reverse(a, a + n);
    idx = n - idx - 1;
    for (int i = idx; i < idx + n; i++) {
      if (a[i % n] != i - idx + 1) {
        f += 1;
        break;
      }
    }
    if (f == 2)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
  return 0;
}
