#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e2 + 10;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOGN = 20;
int arr[MAXN];
signed main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &arr[i]);
    }
    int flag1 = true, flag2 = true;
    for (int i = 0; i < n; ++i) {
      if (arr[i] != 1) continue;
      for (int j = 1; j < n; ++j) {
        if (arr[(i + j) % n] - 1 != arr[(i + j - 1) % n]) {
          flag1 = false;
          break;
        }
      }
      if (!flag1) break;
    }
    for (int i = 0; i < n; ++i) {
      if (arr[i] != n) continue;
      for (int j = 1; j < n; ++j) {
        if (arr[(i + j) % n] + 1 != arr[(i + j - 1) % n]) {
          flag2 = false;
          break;
        }
      }
      if (!flag2) break;
    }
    if (flag1 || flag2)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
