#include <bits/stdc++.h>
using namespace std;
int q, n, a[201], j;
bool flag;
int main() {
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &n);
    for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    j = 2;
    while (j <= n && a[j - 1] + 1 == a[j]) ++j;
    ++j;
    while (j <= n && a[j - 1] + 1 == a[j]) ++j;
    if (j > n) {
      printf("YES\n");
      continue;
    }
    j = 2;
    while (j <= n && a[j - 1] - 1 == a[j]) ++j;
    ++j;
    while (j <= n && a[j - 1] - 1 == a[j]) ++j;
    if (j > n) {
      printf("YES\n");
      continue;
    }
    printf("NO\n");
  }
  return 0;
}
