#include <bits/stdc++.h>
using namespace std;
int main() {
  int queries;
  cin >> queries;
  for (int i = 0; i < queries; i++) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    int cont = 0;
    if (n == 1 || n == 2)
      cout << "YES" << endl;
    else {
      if (abs(v[0] - v[n - 1]) == 1) cont++;
      for (int i = 0; i < n - 1; i++) {
        if (abs(v[i] - v[i + 1]) == 1) cont++;
      }
      if (cont == n - 1)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
