#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a[205];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    int i = 0, s, j, f1 = 1, f2 = 1;
    for (; i < n; i++) {
      if (a[i] == 1) break;
    }
    s = 1;
    j = (i + 1) % n;
    while (a[j] != 1) {
      if (a[j] != s + 1) {
        f1 = 0;
        break;
      }
      s++;
      j++;
      j = j % n;
    }
    s = 1;
    j = (i - 1 + n) % n;
    while (a[j] != 1) {
      if (a[j] != s + 1) {
        f2 = 0;
        break;
      }
      s++;
      j--;
      j = (j + n) % n;
    }
    if (f1 || f2)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
