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