#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  bool flag;
  int n;
  int temp;
  while (q--) {
    flag = false;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
      temp = abs(a[i] - a[i + 1]);
      if (temp != 1 && temp != n - 1) {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
