#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long flag = 0;
    for (long long i = 1; i < n; i++) {
      if (abs(a[i] - a[i - 1]) == 1 || abs(a[i] - a[i - 1]) == n - 1) {
        continue;
      } else {
        cout << "NO"
             << "\n";
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "YES"
           << "\n";
    }
  }
}
