#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, m, n, o, p;
  cin >> p;
  while (p--) {
    cin >> o;
    int x[o];
    for (i = 0; i < o; i++) cin >> x[i];
    m = 0;
    for (i = 1; i < o; i++)
      if (abs(x[i] - x[i - 1]) != 1) m++;
    if (m == 0 || (abs(x[0] - x[o - 1]) == 1 && m == 1))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
