#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
void solve() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int p[n], start = -1;
    for (int i = 0; i < n; ++i) {
      cin >> p[i];
      if (p[i] == 1) start = i;
    }
    bool good = 0, cur = 1;
    for (int i = 0; i < n; ++i) {
      if (p[(start + i) % n] == i + 1) continue;
      cur = 0;
    }
    good |= cur;
    cur = 1;
    for (int i = 0; i < n; ++i) {
      if (p[(start - i + n) % n] == i + 1) continue;
      cur = 0;
    }
    good |= cur;
    if (good)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
void InputSetup() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
int main(void) {
  auto start = chrono::high_resolution_clock::now();
  InputSetup();
  solve();
  auto finish = chrono::high_resolution_clock::now();
  cerr << "Time elapsed: "
       << (chrono::duration<long double>(finish - start)).count() << "s\n";
}
