#include <bits/stdc++.h>
using namespace std;
int main() {
  long long test;
  cin >> test;
  while (test--) {
    long long n, y, x, z, flag = 0;
    cin >> n;
    for (long long i = 0; i < n; i++) {
      y = x;
      cin >> x;
      if (i == 0) {
        z = x;
        continue;
      } else {
        if ((x - y) == 1 || (x - y) == -1)
          continue;
        else
          flag++;
      }
    }
    if ((x - z) == 1 || (x - z) == -1)
      z = 1;
    else
      flag++;
    if (flag <= 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
