#include <bits/stdc++.h>
using namespace std;
int q, n, arr[202];
int main() {
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    bool ok = 1;
    for (int i = 1; i < n; i++) {
      if (arr[i] !=
          (arr[i - 1] + 1 > n ? (arr[i - 1] + 1) % n : arr[i - 1] + 1))
        ok = 0;
    }
    if (arr[0] !=
            (arr[n - 1] + 1 > n ? (arr[n - 1] + 1) % n : arr[n - 1] + 1) &&
        n != 1)
      ok = 0;
    if (ok) {
      printf("YES\n");
      continue;
    }
    ok = 1;
    for (int i = 0; i < n; i++) {
      int j = (i == n - 1 ? 0 : i + 1);
      if (j == i) break;
      if (arr[i] != (arr[j] + 1 > n ? (arr[j] + 1) % n : arr[j] + 1)) ok = 0;
    }
    if (ok) {
      printf("YES\n");
      continue;
    }
    printf("NO\n");
  }
  return 0;
}
