#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n, t, inp, m, f, ini;
  cin >> t;
  while (t-- && cin >> n) {
    m = n, f = 0;
    cin >> ini;
    while (--m && cin >> inp) {
      if (abs(ini - inp) != 1 && abs(ini - inp) != (n - 1)) {
        f = 1;
      }
      ini = inp;
    }
    if (f == 1)
      cout << "NO"
           << "\n";
    else
      cout << "YES"
           << "\n";
  }
}
