#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    bool ans1{1}, ans2{1};
    vector<int> e(n, 0);
    for (int i = 0; i < n; i++) cin >> e[i];
    int in = e[0], inn = e[0];
    for (int i = 0; i < n; i++) {
      if (e[i] == in)
        ;
      else
        ans1 = 0;
      if (e[i] == inn)
        ;
      else
        ans2 = 0;
      if (in != n) {
        in++;
      } else
        in = 1;
      if (inn != 1) {
        inn--;
      } else
        inn = n;
    }
    if (ans1 || ans2)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
  return 0;
}
