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