#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k, arr[205];
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int m1, f1, f2, f;
    f1 = f2 = 0;
    f = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &arr[i]);
      if (i == 1) {
        continue;
      }
      if (!f) {
        k = arr[i];
        m1 = arr[i - 1];
        int s = abs(m1 - k);
        if (s == n - 1 || s == 1) {
          continue;
        } else
          f = 1;
      }
    }
    if (f)
      printf("NO\n");
    else {
      printf("YES\n");
    }
  }
  return 0;
}
