#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    bool ok = 1;
    for (int i = 1; i < n; i++)
      if (a[i] == 1) {
        if (a[i - 1] != n) ok = 0;
      } else if (a[i] != a[i - 1] + 1)
        ok = 0;
    if (ok) {
      cout << "YES" << endl;
      continue;
    }
    ok = 1;
    for (int i = 1; i < n; i++)
      if (a[i] == n) {
        if (a[i - 1] != 1) ok = 0;
      } else if (a[i] != a[i - 1] - 1)
        ok = 0;
    if (ok) {
      cout << "YES" << endl;
      continue;
    }
    cout << "NO" << endl;
  }
}
