#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
int Q, n;
int a[maxn];
int main(int argc, char** argv) {
  scanf("%d", &Q);
  for (int case_ = (1); case_ <= (Q); case_ += (1)) {
    scanf("%d", &n);
    for (int i = (1); i <= (n); i += (1)) scanf("%d", &a[i - 1]);
    int pos_1 = 0;
    for (int i = (1); i <= (n); i += (1))
      if (a[i - 1] == 1) {
        pos_1 = i - 1;
        break;
      }
    bool cw = true, ccw = true;
    for (int i = (1); i <= (n); i += (1)) {
      if (a[(pos_1 + i - 1) % n] != i) cw = false;
      if (a[(pos_1 - i + 1 + n) % n] != i) ccw = false;
    }
    bool res = cw || ccw;
    printf("%s\n", res ? "YES" : "NO");
  }
  return 0;
}
