#include <bits/stdc++.h>
using namespace std;
int main() {
  int g, h, t, y, z;
  bool k, l;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &y);
    int wq[y + 3];
    for (g = 0; g < y; g++) {
      scanf("%d", &wq[g]);
      if (wq[g] == 1) z = g;
    }
    k = l = true;
    for (g = z, h = z + 1; g < z + y - 1; g++, h++) {
      if (wq[g % y] + 1 != wq[(g + 1) % y]) k = false;
      if (wq[h % y] != wq[(h + 1) % y] + 1) l = false;
    }
    if (k || l)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
