#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int a[maxn];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int t, flag = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == 1) t = i;
      a[i + n] = a[i];
    }
    if (n == 1) {
      cout << "YES\n";
      continue;
    }
    for (int i = t; i < n + t - 1; i++) {
      if (a[i + 1] == a[i] + 1) {
        continue;
      } else {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      for (int i = t + n; i > t + 1; i--) {
        if (i == t + 2 && a[i] == a[i - 1] - 1) {
          flag = 0;
          break;
        }
        if (a[i] == a[i - 1] - 1)
          continue;
        else
          break;
      }
    }
    if (flag == 0)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
