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