#include <bits/stdc++.h>
using namespace std;
int Q, N;
int P[205];
int main() {
  cin >> Q;
  if (Q < 1 || Q > 200) return 0;
  while (Q--) {
    cin >> N;
    if (N < 1 || N > 200) {
      return 0;
    }
    for (int i = 0; i < N; i++) {
      cin >> P[i];
    }
    int direction, flag, n1 = N, now = 0, next;
    if (N == 1) {
      cout << "YES" << endl;
      continue;
    }
    direction = P[1] - P[0];
    if (abs(direction) == 1) {
      flag = 1;
    } else
      flag = -1;
    while (n1--) {
      next = (N + flag + now) % N;
      if (abs(P[now] - P[next]) != 1 && abs(P[now] - P[next]) != N - 1) break;
      now = next;
    }
    if (n1 == -1) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}
