#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 1e9 + 7;
;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int q, n, p[202];
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    for (int k = (int)0; k < (int)n; k++) cin >> p[k];
    int ok1 = true, ok2 = true;
    for (int k = (int)0; k < (int)n; k++)
      if (p[k] == 1) {
        for (int i = (int)0; i < (int)n; i++) {
          int x = (k + i) % n;
          if (p[x] != i + 1) ok1 = false;
          int y = (k - i + n) % n;
          if (p[y] != i + 1) ok2 = false;
        }
        break;
      }
    printf("%s\n", (ok1 || ok2) ? "YES" : "NO");
  }
}
