#include <bits/stdc++.h>
using namespace std;
const int Max = 5e5 + 5, Mod = 998244353;
int T, n, a[205];
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    deque<int> q;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      q.push_back(x);
    }
    bool ok = 0;
    for (int i = 0; i < n; i++) {
      bool ook = 1;
      for (int j = 0; j < n; j++)
        if (q[j] != j + 1) ook = 0;
      ok |= ook;
      ook = 1;
      for (int i = 0; i < n; i++)
        if (q[i] != n - i) ook = 0;
      ok |= ook;
      q.push_front(q.back());
      q.pop_back();
    }
    cout << (ok ? "YES" : "NO") << endl;
  }
  return 0;
}
