#include <bits/stdc++.h>
using namespace std;
int const N = 200 + 2;
int n, a[N];
void solve() {
  int plc[N] = {};
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> a[i];
    plc[i + 1] = a[i];
  }
  bool flg = false;
  for (int i = 2; i < (int)(n + 1); ++i) {
    int ck = abs(plc[i] - plc[i - 1]);
    if (!(ck == 1 || ck == n - 1)) flg = true;
  }
  cout << (flg ? "NO" : "YES") << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
