#include <bits/stdc++.h>
using namespace std;
int _, n, p[405], f1, f2, l, r;
int main() {
  scanf("%d", &_);
  while (_--) {
    f1 = f2 = 1;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &p[i]);
      if (p[i] == 1) l = i;
      if (p[i] == n) r = i;
    }
    if (n == 1 || n == 2) {
      printf("YES\n");
      continue;
    }
    for (int i = n; i < 2 * n; i++) p[i] = p[i - n];
    for (int i = l + 1; i < 2 * n; i++) {
      if (p[i] != p[i - 1] + 1) {
        f1 = 0;
        break;
      } else if (p[i] == n)
        break;
    }
    for (int i = r + 1; i < 2 * n; i++) {
      if (p[i] != p[i - 1] - 1) {
        f2 = 0;
        break;
      } else if (p[i] == 1)
        break;
    }
    if (f1 || f2)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
